{"record":{"id":"56bc196473b7a600","repo":"vitest-dev/vitest","slug":"no-property-descriptor-for-globalname-this-is","errorCode":null,"errorMessage":"No property descriptor for ${globalName}, this is a bug in Vitest.","messagePattern":"No property descriptor for (.+?), this is a bug in Vitest\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vitest/src/integrations/env/node.ts","lineNumber":32,"sourceCode":"const nodeGlobals = new Map<string, PropertyDescriptor>()\n\nfunction populateNodeGlobals() {\n  if (nodeGlobals.size !== 0) {\n    return\n  }\n\n  const names = Object.getOwnPropertyNames(globalThis)\n  const length = names.length\n  for (let i = 0; i < length; i++) {\n    const globalName = names[i]\n    if (!denyList.has(globalName)) {\n      const descriptor = Object.getOwnPropertyDescriptor(\n        globalThis,\n        globalName,\n      )\n\n      if (!descriptor) {\n        throw new Error(\n          `No property descriptor for ${globalName}, this is a bug in Vitest.`,\n        )\n      }\n      nodeGlobals.set(globalName, descriptor)\n    }\n  }\n}\n\nexport default <Environment>{\n  name: 'node',\n  viteEnvironment: 'ssr',\n  // this is largely copied from jest's node environment\n  async setupVM() {\n    populateNodeGlobals()\n\n    const vm = await import('node:vm')\n    let context = vm.createContext()\n    let global = vm.runInContext('this', context)","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/vitest-dev/vitest/blob/1fa9837ec26533512fdcad8baebf249771bd340a/packages/vitest/src/integrations/env/node.ts#L14-L50","documentation":"populateNodeGlobals iterates Object.getOwnPropertyNames(globalThis) and immediately calls Object.getOwnPropertyDescriptor for each name. The error fires if getOwnPropertyDescriptor returns undefined for a name that getOwnPropertyNames just returned — a logical impossibility in a single-threaded, stable runtime. The message explicitly says 'this is a bug in Vitest,' signaling an internal invariant violation, likely caused by concurrent modification of globalThis during enumeration.","triggerScenarios":"Another library or a previously-loaded test mutates globalThis (deletes or redefines properties) while populateNodeGlobals is enumerating, so a name returned by getOwnPropertyNames no longer has a descriptor by the time getOwnPropertyDescriptor is called. Also theoretically triggerable by a custom Node build or VM context with non-standard global semantics.","commonSituations":"Extremely rare. Seen in environments where globalThis is being proxied or heavily mutated (e.g. some sandboxing libraries, polyfills that delete/redefine globals during load). Almost always an environment bug, not a user config issue.","solutions":["Identify any code that mutates globalThis during test setup and defer it until after environment initialization.","Update Vitest — newer versions may handle concurrent global mutation more defensively.","If reproducible, file a Vitest bug with the globalThis property name and the mutating library identified."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  // run tests that trigger node environment setup\n} catch (e) {\n  if (e.message.includes('No property descriptor') && e.message.includes('bug in Vitest')) {\n    // report to Vitest; identify globalThis mutator\n  } else throw e\n}","preventionTips":["Avoid libraries that delete/redefine globalThis properties during module load.","Load globalThis-mutating polyfills before the test framework initializes."],"tags":["environment","node","internal-invariant","globalthis"],"backgroundTag":null,"analyzedSha":"1fa9837ec26533512fdcad8baebf249771bd340a","analyzedAt":"2026-08-11T16:11:39.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}