Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

process.cwd.name keeps the main-thread name inside Workers

Aperta
#2,557 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@MathurAditya724 ci sta già lavorando.

Dal 29/10/2026.

  • #2558 di @MathurAditya724 — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
node.js, typescript
Ambito
backend, devtools

Direzione di ricerca

Start with the callable table in packages/compiler/src/frontend/lowering/surfaces.ts near the linked line, then trace how callable boxing and builtin-name inference expose that name to Worker code and aliases. Reproduce with the supplied node:worker_threads case under Node and a compiled executable. Done means the main thread reports "wrappedCwd", workers report "", and callable identity and arity remain unchanged; pull request #2558 is already open.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

When a program reads process.cwd.name inside a Worker, Node returns an empty string. scriptc returns "wrappedCwd", the name of Node's main-thread wrapper, in both threads.

We're evaluating scriptc for the full Sentry CLI and checking the remaining Node compatibility gaps with reduced programs. This case isolates the function-name difference in worker code.

This is a follow-up to #2494, which added stored process.cwd values and resolved #2408. The remaining mismatch affects function metadata observed directly, through imports and saved aliases, or through reflection. The stored function still calls cwd correctly and retains arity zero and one identity across spellings in the reduced cases.

Reproduction

Save this as repro.cjs and run it under Node and as a scriptc-compiled native executable:

const { Worker, isMainThread, parentPort } = require('node:worker_threads');
if (isMainThread) {
  console.log('main', JSON.stringify(process.cwd.name));
  const worker = new Worker(__filename);
  worker.on('message', (name) => console.log('worker', JSON.stringify(name)));
} else {
  parentPort.postMessage(process.cwd.name);
}

Observed with Node 24.22.0:

main "wrappedCwd"
worker ""

Observed in the native executable built from current compiler sources:

main "wrappedCwd"
worker "wrappedCwd"

The expanded CommonJS and ESM regressions also reproduce the mismatch through the global, module, named/default imports, const/destructured aliases, and Reflect.get. Their main-thread observations match Node before and after the Worker exits; only the worker names differ.

Cause and expected behavior

The process callable table assigns one unconditional valueName: "wrappedCwd". Callable boxing and builtin-name inference reuse that value, so worker code inherits the main-thread name. A correction needs to preserve the existing callable identity and arity while selecting the name for the executing thread, including when aliases are boxed for reflection.

The main thread should keep "wrappedCwd", and workers should expose "". Quoted/computed destructuring-name issues raised separately on #2494 are outside this report's scope.

Reproduction context

Source revision checked, with the unconditional callable name.

The local source host uses unmodified 0.4.5 macOS arm64 LLVM/runtime artifacts from successful CI. Their owning native source and build inputs match the checked development revision; their original package identity is retained through the supported source-host API. The pending 0.4.6 release was not substituted or relabeled.

Lingua principale
TypeScript
Stelle
6.4k
Fork
201
Merge medio
6h 56m
PR unite (30g)
916

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di vercel-labs/scriptc

Tutte le issue di vercel-labs/scriptc

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.