Skip to content

bug: WASM complexity fails — findFunctionNode is not defined #413

@carlos-alm

Description

@carlos-alm

Found during dogfooding v3.1.2

Severity: High
Command: codegraph build --engine wasmcodegraph complexity

Reproduction

codegraph build . --engine wasm --no-incremental --verbose
# stderr: [codegraph DEBUG] buildComplexityMetrics failed: findFunctionNode is not defined
codegraph complexity -T
# "No complexity data found"

Expected behavior

WASM builds should produce complexity metrics just like native builds.

Actual behavior

buildComplexityMetrics throws ReferenceError: findFunctionNode is not defined and the entire complexity phase is silently skipped. The function_complexity table has 0 rows after a WASM build.

Root cause

In src/complexity.js:

  • Line 9: import { findFunctionNode as _findFunctionNode } from './ast-analysis/shared.js'
  • Line 331: export { _findFunctionNode as findFunctionNode } (re-export only)
  • Line 457: const funcNode = findFunctionNode(tree.rootNode, ...) — uses bare name

The import aliases the function to _findFunctionNode, but line 457 references the bare findFunctionNode which is not a local binding (only a re-export name). On native builds this never triggers because def.complexity is pre-computed at line 425 and the code continues before reaching 457. On WASM builds, there's no pre-computed complexity so execution falls through to 457.

Suggested fix

Change line 457 from findFunctionNode(...) to _findFunctionNode(...).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdogfoodFound during dogfooding

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions