JS: the EventEmitter pass pairs emit/on by event name only and picks the handler by name project-wide
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 55/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- javascript, node.js, typescript
- Ambito
- tooling
Direzione di ricerca
Start in src/resolution/callback-synthesizer.ts around lines 385-386, where ctx.getNodesByName(handlerName) takes the first match project-wide, and in the handler map that is keyed only by the event string. Reproduce with the two-module example (src/a_cart.js, src/b_profile.js) using CODEGRAPH_KERNEL=0, then check how the pass knows the registering file and receiver binding. Done means saveProfile links to b_profile's handleSave, no cross links appear, and synthesized edges carry a line.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
The EventEmitter synthesis pass pairs emitters and handlers by event name alone, and looks up a registered handler by name anywhere in the project. Two modules that each use their own emitter with the same event name and a same-named handler cross-link.
// src/a_cart.js
const EventEmitter = require('events')
const cart = new EventEmitter()
function handleSave () { return 'cart' }
cart.on('save', handleSave)
function saveCart () { cart.emit('save') }
// src/b_profile.js
const EventEmitter = require('events')
const profile = new EventEmitter()
function handleSave () { return 'profile' }
profile.on('save', handleSave)
function saveProfile () { profile.emit('save') }
edge on main (synthesized) |
expected |
|---|---|
saveCart → handleSave (a_cart.js:3) ✓ |
same |
saveProfile → handleSave (a_cart.js:3) ✗ |
handleSave in b_profile.js |
b_profile.js's own handleSave gets no synthesized caller. With distinct handler names (onCartSaved / onProfileSaved), each emitter links to both handlers, so all four cross pairs appear (from an audit run; not re-run here). The synthesized edges also carry no line (line: null).
Cause. callback-synthesizer.ts#L385-L386: ctx.getNodesByName(handlerName).find(...) takes the first function of that name anywhere, not the one in the registering file. The handler map is keyed only by event string, so the receiver (cart vs profile) is never compared.
Reproduced on main at 77ee3484 with CODEGRAPH_KERNEL=0. Linux/WSL2, Node 22.23.2.
Expected. Resolve the handler name in the registering file's scope first (as a bare call there would), and pair emit with on only when the receivers can be the same object (same binding or import), not on the event string alone. Generic names (save, change, error, data) are exactly the ones that collide.
- Lingua principale
- C
- Stelle
- 73.2k
- Fork
- 4.7k
- Merge medio
- 3h 31m
- PR unite (30g)
- 546
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
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 colbymchenry/codegraph
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
colbymchenry/codegraph#3093 ·
I maintainer di solito rispondono entro 1 giorno
-
Windows: npm-shim spawnSync missing windowsHide flashes a console window on every MCP server launchAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
colbymchenry/codegraph#3054 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
colbymchenry/codegraph#2974 ·
I maintainer di solito rispondono entro 1 giorno
-
[Security Vulnerabiliy] Vulnerable bundled `node.exe` detected (Node2Shell - CVE-2026-111497)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
colbymchenry/codegraph#2959 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
codegraph ui - does not workAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
colbymchenry/codegraph#1900 · 2 commenti · 5 reazioni ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di colbymchenry/codegraph
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
area:docs area:stdlib found-by:duet-audit kind:docs-drift
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
InauguralSystems/EigenScript#2251 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
flux-framework/flux-coral2#513 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
ly05010419/MacNativeGames#1420 ·
I maintainer di solito rispondono entro 1 giorno
-
Isaac workingAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
seedds/nxnative#763 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno