{"record":{"id":"52346bee64ce4e86","repo":"denoland/deno","slug":"name-is-already-registered","errorCode":null,"errorMessage":"${name} is already registered","messagePattern":"(.+?) is already registered","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"libs/core/01_core.js","lineNumber":727,"sourceCode":"    op_shutdown: shutdown,\n    op_is_terminal: isTerminal,\n  } = ops;\n\n  const callSiteRetBuf = new Uint32Array(2);\n  const callSiteRetBufU8 = new Uint8Array(callSiteRetBuf.buffer);\n\n  function currentUserCallSite() {\n    const fileName = op_current_user_call_site(callSiteRetBufU8);\n    const lineNumber = callSiteRetBuf[0];\n    const columnNumber = callSiteRetBuf[1];\n    return { fileName, lineNumber, columnNumber };\n  }\n\n  const hostObjectBrand = SymbolFor(\"Deno.core.hostObject\");\n  const transferableResources = {};\n  const registerTransferableResource = (name, send, receive) => {\n    if (transferableResources[name]) {\n      throw new Error(`${name} is already registered`);\n    }\n    transferableResources[name] = { send, receive };\n  };\n  const getTransferableResource = (name) => transferableResources[name];\n  const cloneableDeserializers = { __proto__: null };\n  const registerCloneableResource = (name, deserialize) => {\n    if (cloneableDeserializers[name]) {\n      throw new Error(`${name} is already registered`);\n    }\n    cloneableDeserializers[name] = deserialize;\n  };\n  const getCloneableDeserializers = () => cloneableDeserializers;\n\n  // A helper function that will bind our own console implementation\n  // with default implementation of Console from V8. This will cause\n  // console messages to be piped to inspector console.\n  //\n  // We are using `Deno.core.callConsole` binding to preserve proper stack","sourceCodeStart":709,"sourceCodeEnd":745,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/libs/core/01_core.js#L709-L745","documentation":"Deno.core.registerTransferableResource(name, send, receive) installs the serializer/deserializer pair used when a resource of that kind crosses a worker postMessage boundary. Names key a single global registry in 01_core.js and must be unique; registering an existing name throws `Error: ${name} is already registered` because structured clone could not decide which receive function to trust. This is an internal API used when building extensions or custom runtime snapshots.","triggerScenarios":"Two extensions registering a transferable resource under the same name during snapshot bootstrap; an extension's init JavaScript being evaluated twice; a forked/copied extension keeping the original resource name.","commonSituations":"Building custom runtimes with deno_core's ExtensionBuilder JS snippets; name collisions between first-party and third-party extensions (e.g. two variants both registering a body/file resource); duplicate bootstrap in tests.","solutions":["Give each registration a unique, namespaced name such as 'myExt.myResource'","Check `core.getTransferableResource(name)` is undefined first, and skip or fail with a clearer diagnostic","Make the extension's init script idempotent and ensure it loads exactly once (deduplicate the extension list)"],"exampleFix":"// before\ncore.registerTransferableResource('blob', send, receive); // second registration of 'blob' throws\n\n// after\nif (core.getTransferableResource('myExt.blob') === undefined) {\n  core.registerTransferableResource('myExt.blob', send, receive);\n}","handlingStrategy":"validation","validationCode":"if (core.getTransferableResource(name) !== undefined) {\n  throw new Error(`transferable resource '${name}' is already registered`);\n}\ncore.registerTransferableResource(name, send, receive);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Namespace resource names by extension (myExt.resource) so collisions cannot happen silently","Register in exactly one place during extension init; never re-run init scripts","Fail fast at startup on duplicate registrations so the offending extension is obvious"],"tags":["deno-core","extensions","resource-registry","internal","registration"],"backgroundTag":"duplicate-registration","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}