process.cwd.name keeps the main-thread name inside Workers
I maintainer di solito rispondono entro 1 giorno
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
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
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di vercel-labs/scriptc
-
util.format %o passes the wrong showHidden flag to custom inspectorsForse già presa @MathurAditya724 l’ha presa 1 giorno fa. Aperta
Difficoltà 4/5 1-2 giorni Idoneità per principianti 35/100
vercel-labs/scriptc#2571 ·
I maintainer di solito rispondono entro 1 giorno
-
SC2003 'string | undefined' when a method returning an element of its array field is used inlineAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
vercel-labs/scriptc#2400 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
vercel-labs/scriptc#2399 ·
I maintainer di solito rispondono entro 1 giorno
-
Large LLVM metadata tables crash compilation with a stack overflowForse già presa @MathurAditya724 l’ha presa 4 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 22/100
vercel-labs/scriptc#2394 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
vercel-labs/scriptc#2209 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di vercel-labs/scriptc
Issue simili
-
Add: Disco Mix SDApertacheck:passed streams:add
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
level2 nsoc26
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
GauravKarakoti/SecureFlow#1488 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
deltachat/deltachat-desktop#6914 ·
I maintainer di solito rispondono entro 2 giorni
-
area:cli bug P4
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
bug from-studio
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
esengine/DeepSeek-Reasonix#14868 ·
I maintainer di solito rispondono entro 1 giorno