{"record":{"id":"7728cf953e64f1c3","repo":"tursodatabase/turso","slug":"invalid-config-url-is-required","errorCode":null,"errorMessage":"invalid config: url is required","messagePattern":"invalid config: url is required","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"serverless/javascript/src/connection.ts","lineNumber":129,"sourceCode":" * ]);\n *\n * // Option 2: reusable pool for repeated parallel work\n * const pool = Array.from({ length: 4 }, () => connect(config));\n * const results = await Promise.all(\n *   queries.map((sql, i) => pool[i % pool.length].all(sql))\n * );\n * ```\n */\nexport class Connection {\n  private config: Config;\n  private session: Session;\n  private isOpen: boolean = true;\n  private defaultSafeIntegerMode: boolean = false;\n  private execLock: AsyncLock = new AsyncLock();\n\n  constructor(config: Config) {\n    if (!config.url) {\n      throw new Error(\"invalid config: url is required\");\n    }\n    this.config = config;\n    this.session = new Session(config);\n\n    // Define inTransaction property\n    Object.defineProperty(this, 'inTransaction', {\n      get: () => this.session.inTransaction,\n      enumerable: true\n    });\n  }\n\n  /**\n   * Whether the database is currently in a transaction.\n   *\n   * Derived from the server's `get_autocommit` status (refreshed on every\n   * request), so it reflects the connection's real transaction state — the\n   * same as `sqlite3_get_autocommit()` on the native bindings — including\n   * transactions opened with a raw `BEGIN`, not just via `transaction()`.","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/tursodatabase/turso/blob/c1e59287258d99b309e362a63f48822256e2f65f/serverless/javascript/src/connection.ts#L111-L147","documentation":"The Connection constructor validates the config synchronously and throws when `config.url` is missing or empty. Every statement this class executes is an HTTP round trip to that URL, so there is no default endpoint and construction cannot proceed without one.","triggerScenarios":"`new Connection({ authToken })` with no url; a url read from an unset environment variable (undefined) or an empty string; a typo'd config key such as `uri` or `endpoint`.","commonSituations":"Deployments missing TURSO_DATABASE_URL / LIBSQL_URL; CI running with a partial .env; config objects assembled conditionally where one branch omits the url key.","solutions":["Set url to the database endpoint (libsql://... or https://...)","Fail fast at startup if the env var is missing, before constructing the Connection","Double-check the config key is exactly `url`"],"exampleFix":"// before\nconst conn = new Connection({ authToken: process.env.TURSO_AUTH_TOKEN });\n// after\nconst url = process.env.TURSO_DATABASE_URL;\nif (!url) throw new Error('TURSO_DATABASE_URL is not set');\nconst conn = new Connection({ url, authToken: process.env.TURSO_AUTH_TOKEN });","handlingStrategy":"validation","validationCode":"if (typeof config?.url !== 'string' || config.url.length === 0) {\n  throw new Error('Connection requires config.url (e.g. libsql://db.turso.io)');\n}\nconst conn = new Connection(config);","typeGuard":"const hasUrl = (c: Config): c is Config & { url: string } =>\n  typeof c?.url === 'string' && c.url.length > 0;","tryCatchPattern":null,"preventionTips":["Validate env-derived config once at boot and fail fast with a clear message","Use a schema validator (zod) for config objects so a missing url never reaches the constructor"],"tags":["config","constructor","validation","env"],"backgroundTag":"missing-required-config","analyzedSha":"c1e59287258d99b309e362a63f48822256e2f65f","analyzedAt":"2026-08-20T07:02:18.389Z","contentChangedAt":"2026-08-20T07:02:18.389Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}