Skip to content

Calls inside anonymous callbacks are dropped from the call graph (JS/TS) — find_callers misses them #1570

Closed

Description

@thackerronak

Summary

A function call whose nearest enclosing function is an anonymous callback (the arrow/function passed to setTimeout, .then, app.use, an event handler, …) is not recorded as a CALLS edge, so find_callers misses it. The call is attributed to a nameless caller and dropped, instead of to the nearest named enclosing function.

For agent/LLM consumers this is an incompleteness problem: a blast-radius query silently omits real call sites that happen to live inside callbacks.

Environment

  • codegraphcontext==0.5.5 (PyPI); also main
  • Python 3.13, macOS arm64
  • Backend: embedded FalkorDB (-db falkordb)
  • Languages: TypeScript (.ts, .tsx) and JavaScript

Reproduction

// probe.ts
export const requestTimeout = (req, res, next) => {
  setTimeout(() => {
    customErrorHandler(req, res);   // ← call inside an anonymous callback
  }, 1000);
};
function customErrorHandler(...args: unknown[]) {}
cgc -db falkordb index /tmp/probe --force
cgc -db falkordb analyze callers customErrorHandler
# → requestTimeout is absent (0 callers reported)

Observed on a real file: a symbol with 55 grep-confirmed call sites returns 54 from find_callers; the single miss is a call inside a setTimeout(() => { … }) arrow nested in a named function.

Root cause

_get_parent_context (tools/languages/typescript.py, javascript.py; .tsx inherits from the TS parser) walks up to the first function-like node, and arrow_function / function_expression are in the match set. When that node is an anonymous callback it cannot resolve a name and returns a nameless caller:

return self._get_node_text(name_node) if name_node else None, curr.type, curr.start_point[0] + 1

A caller with no name produces no node, so the CALLS edge is dropped. The walk stops at the anonymous scope instead of continuing to the enclosing named function (e.g. requestTimeout).

(Python is unaffected — its _get_parent_context matches only named function_definition / class_definition; lambdas can't hold statement calls.)

Activity

  1. github-actions commented on Aug 3, 2026

    @github-actions
    Contributor

    Hi! 👋 Join our CodeGraphContext Discord channel to collaborate: https://discord.gg/dR4QY32uYQ

  2. Shriraj888 commented on Aug 4, 2026

    @Shriraj888
    Contributor

    i would like to work on this issue , under GSSoC '26 , /assign

  3. shanmukhdatta commented on Aug 11, 2026

    @shanmukhdatta
    Contributor

    Hi, I'd like to work on this issue for GSSoC 2026. I can get a PR up by tomorrow. Could you please assign it to me? Thanks!

  4. moved this from Backlog tasks to In progress in CGC Progress Boardon Aug 14, 2026
  5. moved this from In progress to Done in CGC Progress Boardon Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions