{"record":{"id":"7b68d6692541bd22","repo":"denoland/deno","slug":"err-construct-call-required-7b68d6","errorCode":"ERR_CONSTRUCT_CALL_REQUIRED","errorMessage":"Cannot call constructor without `new`","messagePattern":"Cannot call constructor without `new`","errorType":"validation","errorClass":"ConstructCallRequiredError","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/sqlite.ts","lineNumber":160,"sourceCode":"    typeof parsedPath === \"undefined\" ||\n    StringPrototypeIncludes(parsedPath, \"\\0\")\n  ) {\n    throw new InvalidArgTypeError(\n      'The \"path\" argument must be a string, Uint8Array, or URL without null bytes.',\n    );\n  }\n\n  return parsedPath;\n};\n\n// Using ES5 class allows custom error to be thrown\n// when called without `new`.\nfunction DatabaseSync(\n  path,\n  options,\n) {\n  if (new.target === undefined) {\n    throw new ConstructCallRequiredError();\n  }\n  return ReflectConstruct(\n    DatabaseSyncOp,\n    [parsePath(path), options],\n    new.target,\n  );\n}\nObjectSetPrototypeOf(DatabaseSync.prototype, DatabaseSyncOp.prototype);\nObjectSetPrototypeOf(DatabaseSync, DatabaseSyncOp);\n\nfunction validateBackupOptions(options) {\n  if (options === undefined) {\n    return;\n  }\n  if (typeof options !== \"object\" || options === null) {\n    throw new InvalidArgTypeError(\n      'The \"options\" argument must be an object.',\n    );","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/node/polyfills/sqlite.ts#L142-L178","documentation":"DatabaseSync is an ES5-style wrapper function around the native op class so that it can validate the call form. Invoking it as a plain function (`DatabaseSync(':memory:')`) skips construction, so the wrapper checks `new.target === undefined` and throws ERR_CONSTRUCT_CALL_REQUIRED ('Cannot call constructor without `new`') before any native code runs.","triggerScenarios":"`const db = DatabaseSync('db.sqlite')` without `new`; aliasing the class (`const connect = DatabaseSync; connect(path)`) or passing it as a callback (`.map(DatabaseSync)`), which loses construct semantics.","commonSituations":"Porting better-sqlite3 factory-style wrappers (`connect(path)`); bundled/minified code that drops `new`; calling via `.call(null, path)`.","solutions":["Always construct with `new`: `new DatabaseSync(path)`","Wrap in an explicit factory that forwards with new: `const connect = (path) => new DatabaseSync(path)`","When passing constructors as callbacks, use arrow wrappers: `.map((p) => new DatabaseSync(p))`"],"exampleFix":"// before\nconst db = DatabaseSync('app.db');\n// ERR_CONSTRUCT_CALL_REQUIRED\n\n// after\nconst db = new DatabaseSync('app.db');\n// or a factory wrapper\nconst connect = (path) => new DatabaseSync(path);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const db = DatabaseSync(path); // forgot `new`\n} catch (e) {\n  if (e.code === 'ERR_CONSTRUCT_CALL_REQUIRED') {\n    throw new Error('DatabaseSync must be called with `new`');\n  }\n  throw e;\n}","preventionTips":["Use `new` for every node:sqlite class (DatabaseSync, and via it StatementSync)","Prefer small factory functions over passing constructors as callbacks","Lint for `.map(DatabaseSync)`-style constructs that drop `new`"],"tags":["sqlite","constructor","node-compat"],"backgroundTag":"constructor-called-without-new","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}