{"record":{"id":"d1cfb0d41c67d118","repo":"denoland/deno","slug":"unable-to-convert","errorCode":null,"errorMessage":"unable to convert","messagePattern":"unable to convert","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"libs/core/runtime/bindings.rs","lineNumber":316,"sourceCode":"    )\n  }\n}\n\npub(crate) fn get<'s, 'i, T>(\n  scope: &mut v8::PinScope<'s, 'i>,\n  from: v8::Local<'s, v8::Object>,\n  key: FastStaticString,\n  path: &'static str,\n) -> T\nwhere\n  v8::Local<'s, v8::Value>: TryInto<T>,\n{\n  let key = key.v8_string(scope).unwrap();\n  from\n    .get(scope, key.into())\n    .unwrap_or_else(|| panic!(\"{path} exists\"))\n    .try_into()\n    .unwrap_or_else(|_| panic!(\"unable to convert\"))\n}\n\n/// Create an object on the `globalThis` that looks like this:\n/// ```ignore\n/// globalThis.Deno = {\n///   core: {\n///     ops: {},\n///   },\n///   // console from V8\n///   console,\n///   // wrapper fn to forward message to V8 console\n///   callConsole,\n/// };\n/// ```\npub(crate) fn initialize_deno_core_namespace<'s, 'i>(\n  scope: &mut v8::PinScope<'s, 'i>,\n  context: v8::Local<'s, v8::Context>,\n  init_mode: InitMode,","sourceCodeStart":298,"sourceCodeEnd":334,"githubUrl":"https://github.com/denoland/deno/blob/336da420f4343cbb1dcbd5eed9d075ff555ed6ee/libs/core/runtime/bindings.rs#L298-L334","documentation":"The second failure mode of bindings::get(): the property at the given path exists, but converting the v8 value to the expected Rust type (v8::Object, v8::Function, etc. via TryInto) fails, so the \"unable to convert\" panic fires. This means the global shape is present but wrong: something replaced a binding with a value of a different type before deno_core grabbed it. Typical sources are user/middleware JavaScript overwriting internals, or a snapshot from an incompatible deno_core version where the path holds a different kind of value.","triggerScenarios":"A startup script or global_object_middleware assigning a non-object to globalThis.Deno.core (e.g. a string or plain shim) before runtime init; a snapshot built by a deno_core version where an expected Function binding (event loop tick, timers, error constructors) was an Object or undefined; JS running between context creation and bindings::get that mutates Deno internals.","commonSituations":"Embedders monkey-patching Deno.core in bootstrap code; snapshot/binary version skew after a dependency bump; polyfill libraries loaded eagerly that replace built-ins wholesale instead of extending them.","solutions":["Find the code that overwrites the binding and make it extend the existing object instead of replacing it","Regenerate the startup snapshot with the same deno_core version as the binary so every binding has the expected type","Audit global_object_middlewares for code that runs before init and returns/sets different types","If patching is required, do it after JsRuntime initialization completes, not during startup"],"exampleFix":"// before (startup script runs before core grabs bindings):\nglobalThis.Deno = { core: { ops: 'shim' } }; // replaces real objects with a string\n\n// after: extend, never replace\nconst deno = globalThis.Deno;\nglobalThis.Deno = { ...deno, extraFlag: true };","handlingStrategy":"validation","validationCode":"// Guard in bootstrap scripts: verify the binding shape before touching it.\nif (typeof globalThis.Deno?.core?.ops !== 'object' || globalThis.Deno.core.ops === null) {\n  throw new Error('Deno.core.ops missing or wrong type; refusing to patch');\n}","typeGuard":"// TypeScript: narrow before patching internals\nfunction hasDenoCore(v: unknown): v is { core: { ops: Record<string, unknown> } } {\n  return !!v && typeof v === 'object'\n    && 'core' in v && typeof (v as any).core === 'object'\n    && 'ops' in (v as any).core && typeof (v as any).core.ops === 'object';\n}","tryCatchPattern":null,"preventionTips":["Extend existing globals (spread) instead of replacing them","Apply monkey-patches after JsRuntime initialization completes, never during startup","Regenerate snapshots on every deno_core bump so binding types stay in sync","Add a startup assertion that required bindings exist and have the expected types"],"tags":["deno-core","v8","type-mismatch","runtime-init","snapshot","panic"],"backgroundTag":"runtime-initialization-failed","analyzedSha":"336da420f4343cbb1dcbd5eed9d075ff555ed6ee","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}