JS: the EventEmitter pass pairs emit/on by event name only and picks the handler by name project-wide
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 55/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- javascript, node.js, typescript
- Domínio
- tooling
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- C
- Estrelas
- 73.2k
- Forks
- 4.7k
- Merge médio
- 3h 37min
- PRs com merge (30d)
- 533
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de colbymchenry/codegraph
-
A `../` entry in package.json `workspaces` makes a folder outside the project count as a workspace package, and a call gets linked to the wrong functionTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
colbymchenry/codegraph#3093 ·
Mantenedores costumam responder em até 1 dia
-
Windows: npm-shim spawnSync missing windowsHide flashes a console window on every MCP server launchAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 86/100
colbymchenry/codegraph#3054 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
colbymchenry/codegraph#2974 ·
Mantenedores costumam responder em até 1 dia
-
[Security Vulnerabiliy] Vulnerable bundled `node.exe` detected (Node2Shell - CVE-2026-111497)Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 66/100
colbymchenry/codegraph#2959 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
codegraph ui - does not workAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
colbymchenry/codegraph#1900 · 2 comentários · 5 reações ·
Mantenedores costumam responder em até 1 dia
Todas as issues de colbymchenry/codegraph
Issues semelhantes
-
Dificuldade 2/5 Meio dia Facilidade para iniciantes 62/100
php/php-src#25137 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
c3lang/c3c#3613 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
es-ude/OnDeviceTraining#511 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
STMicroelectronics/STSELib#128 ·