{"record":{"id":"90f886e1d695ffe9","repo":"immerjs/immer","slug":"immer-minified-error-nr-error-full-error-at","errorCode":null,"errorMessage":"[Immer] minified error nr: ${error}. Full error at: https://bit.ly/3cXEKWf","messagePattern":"\\[Immer\\] minified error nr: (.+?)\\. Full error at: https://bit\\.ly/3cXEKWf","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/utils/errors.ts","lineNumber":47,"sourceCode":"\t\t\t\t\"Object.defineProperty() cannot be used on an Immer draft\",\n\t\t\t\t\"Object.setPrototypeOf() cannot be used on an Immer draft\",\n\t\t\t\t\"Immer only supports deleting array indices\",\n\t\t\t\t\"Immer only supports setting array indices and the 'length' property\",\n\t\t\t\tfunction (thing: string) {\n\t\t\t\t\treturn `'original' expects a draft, got: ${thing}`\n\t\t\t\t}\n\t\t\t\t// Note: if more errors are added, the errorOffset in Patches.ts should be increased\n\t\t\t\t// See Patches.ts for additional errors\n\t\t\t]\n\t\t: []\n\nexport function die(error: number, ...args: any[]): never {\n\tif (process.env.NODE_ENV !== \"production\") {\n\t\tconst e = errors[error]\n\t\tconst msg = isFunction(e) ? e.apply(null, args as any) : e\n\t\tthrow new Error(`[Immer] ${msg}`)\n\t}\n\tthrow new Error(\n\t\t`[Immer] minified error nr: ${error}. Full error at: https://bit.ly/3cXEKWf`\n\t)\n}\n","sourceCodeStart":29,"sourceCodeEnd":51,"githubUrl":"https://github.com/immerjs/immer/blob/d2c158f5bac7081a760bbaf501ea5c360b7856e1/src/utils/errors.ts#L29-L51","documentation":"The production-mode throw in die() (src/utils/errors.ts:47-49). When process.env.NODE_ENV === \"production\", the errors table is replaced with [] (src/utils/errors.ts:39), so the dev branch (and its message strings) is dead-stripped at build time and only this compact branch ships. It discards the formatted text and emits just the numeric code plus a link (https://bit.ly/3cXEKWf, Immer's error docs) to minimize bundle size. The number maps 1:1 to an index in the development errors array.","triggerScenarios":"Identical conditions to the dev-mode die - any die(n) call - but encountered inside a production bundle (webpack/esbuild/rollup build with NODE_ENV=production, or a published/minified dependency). Execution still halts with a thrown Error; you simply lose the human-readable message and receive only the number.","commonSituations":"Errors that surface only in staging or production; a dependency whose build set NODE_ENV=production, stripping the message table; difficulty mapping the bare number to a root cause without the dev build; a bundler that left process.env.NODE_ENV undefined, producing inconsistent error output.","solutions":["Reproduce the same input under NODE_ENV=development (or a non-production build) to obtain the full [Immer] message for that code number.","Map the number to its message using the dev errors table (src/utils/errors.ts:3-38; codes >= 16 live in the patches plugin block at src/plugins/patches.ts:36-48 with errorOffset 16).","Apply the fix the dev message prescribes - the root cause is identical to the dev-mode error.","Confirm your bundler replaces process.env.NODE_ENV correctly at build time so you do not ship a mixed or undefined state."],"exampleFix":"// before: opaque error in a production bundle\n// -> [Immer] minified error nr: 1. Full error at: https://bit.ly/3cXEKWf\n\n// after: reproduce locally with a dev build to see the real message\n// NODE_ENV=development <run your app/tests>\n// -> [Immer] produce can only be called on things that are draftable: ...","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// In production the message is opaque, so capture and log the code number,\n// then reproduce the same input under NODE_ENV=development for the full text.\ntry {\n  nextState = produce(state, draft => {\n    /* recipe */\n  })\n} catch (err) {\n  if (err instanceof Error && err.message.includes(\"[Immer] minified error nr:\")) {\n    const nr = err.message.match(/nr:\\s*(\\d+)/)?.[1]\n    logger.error(\"Immer production error\", {code: nr, input: state})\n    // map `nr` against src/utils/errors.ts (0-15) or patches errorOffset (16+)\n  }\n  throw err\n}","preventionTips":["Reproduce any production Immer error under NODE_ENV=development to recover the full message before fixing.","Map the numeric code to its text using src/utils/errors.ts:3-38 (codes 0-15) and src/plugins/patches.ts:36-48 (codes 16-19, errorOffset 16).","Verify your bundler statically replaces process.env.NODE_ENV so dev error code is never shipped and prod builds strip the message table cleanly.","Run the same isDraftable/isDraft pre-checks from the dev-mode strategy during development so the misuse never reaches production.","Add a try/catch around produce()/applyPatches() at trust boundaries to log the code and input for post-deploy triage."],"tags":["die","production","minified","error-handling","bundle"],"backgroundTag":null,"analyzedSha":"d2c158f5bac7081a760bbaf501ea5c360b7856e1","analyzedAt":"2026-08-13T09:59:10.681Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}