Skip to content

TS/JS: calls edges silently dropped for callback bodies passed to generic higher-order functions (onCall-style) — still reproduces on v0.9.35 #2552

Closed

Description

@Earthfreedom

Summary

graphify extract --code-only produces zero calls edges for any call made from inside a callback function's body when that callback is passed as an argument to a generic higher-order function (e.g. wrapper(async (req) => { ... })) — the exact shape used by Firebase's onCall/onDocumentWritten, Express middleware, array.map(async (x) => ...), and similar frameworks. An identical call made from a normal named function or class method is captured correctly.

This was previously reported in #1630 (claimed fixed for closures in v0.9.11) and #1740 (closed as a duplicate/fixed), and reported again as a regression in #2143 (still open). This report reproduces it fresh on v0.9.35, the latest release as of this writing, with a minimal, framework-free test case, confirming it is not fixed by the #1630 change and #2143 is not stale.

Environment

  • graphifyy version: 0.9.33 and 0.9.35 (both tested; identical behavior)
  • Python: 3.12.13
  • OS: Linux (python:3.12-slim Docker container; host OS macOS 26.5.1/Docker Desktop, irrelevant to the bug — verified in a clean container both times)
  • Invocation: graphify extract <path> --code-only --no-cluster

Minimal reproduction

4 files, no dependencies, no Firebase SDK required (a hand-rolled generic wrapper reproduces the same AST shape as onCall's generic-callback signature).

helpers.ts

export function helperA(): void {
  console.log('helperA called');
}

export class Service {
  method(): Promise<void> {
    return Promise.resolve();
  }
}

wrapper.ts

// Generic higher-order function, structurally similar to Firebase's
// `onCall<T, Return>(handler: (request: CallableRequest<T>) => Return)`.
export function wrapper<T>(
  fn: (req: T) => Promise<void>,
): (req: T) => Promise<void> {
  return fn;
}

handler.ts — the callback case under test:

import { wrapper } from './wrapper';
import { helperA, Service } from './helpers';

// Callback case: the async arrow function is passed as an argument to a
// generic higher-order function (the pattern used by Firebase's onCall,
// onDocumentWritten, Express middleware, etc). Calls made from inside this
// arrow's body should still produce `calls` edges to helperA and
// Service.method.
export const handler = wrapper(async (req: unknown) => {
  helperA();
  await new Service().method();
});

control.ts — control group: identical calls, but from a normal function and a class method (no callback into a higher-order function):

import { helperA, Service } from './helpers';

export function normalCaller(): void {
  helperA();
  new Service().method();
}

export class ControlClass {
  run(): void {
    helperA();
    new Service().method();
  }
}

Run:

graphify extract . --code-only --no-cluster

Expected vs Actual

Expected: handler's callback body calls helperA(), so a calls edge from the handler node to helperA should exist — just like normalCaller() and ControlClass.run() get one.

Actual (identical on v0.9.33 and v0.9.35):

$ jq '[.edges[] | select(.source=="handler_handler")]' graph.json
[]

Zero edges of any kind originate from the callback body's node. Meanwhile the control group resolves correctly:

$ jq '[.edges[] | select(.relation=="calls")]' graph.json
[
  {
    "source": "control_normalcaller",
    "target": "helpers_helpera",
    "relation": "calls",
    "context": "call",
    "confidence": "EXTRACTED",
    "confidence_score": 1.0,
    "source_file": "control.ts",
    "source_location": "L6",
    "weight": 1.0
  },
  {
    "source": "control_controlclass_run",
    "target": "helpers_helpera",
    "relation": "calls",
    "context": "call",
    "confidence": "EXTRACTED",
    "confidence_score": 1.0,
    "source_file": "control.ts",
    "source_location": "L12",
    "weight": 1.0
  }
]

handler.ts produces exactly one handler_handler node (the exported const) and one contains edge from the file node into it — nothing else. The two helperA/Service imports into handler.ts are extracted fine (imports/imports_from edges exist), so the file-level import resolution works; only the call graph inside the callback body is dropped.

Impact

On a real Firebase Cloud Functions codebase (TypeScript, onCall/onDocumentWritten/onDocumentCreated handlers — the exact "callback passed to a generic higher-order function" shape), 38 of 42 Cloud Functions entry points had zero outgoing calls edges in the extracted graph — i.e. 90% of the actual business logic invoked from Cloud Functions handlers (service calls, repository calls, validation, AI provider calls) is invisible to graphify query/graphify affected/graphify god-nodes, making the tool blind to the majority of real runtime call chains for a serverless/event-driven codebase.

Related issues

This report adds a minimal, framework-independent repro and confirms the defect is present on the current latest release (v0.9.35), not just old/cached behavior.

Activity

  1. safishamsi commented on Aug 8, 2026

    @safishamsi
    Member

    Fixed in v0.9.37. Calls inside a callback body passed to another call (e.g. export const handler = wrapper(async (req) => { helper() })) are now walked and attributed to the declaration, through the same import-gated resolution so they cannot fabricate edges. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions