microsoft/typescript-go · error · ErrClientError

%w: invalid node handle %q: %w

Error message

%w: invalid node handle %q: %w

What it means

Error "%w: invalid node handle %q: %w" thrown in microsoft/typescript-go.

Source

Thrown at internal/api/session.go:3287

	return setup.sd.newTypeResponse(params.Project, setup.checker.GetFalseTypeOfConditionalType(t)), nil
}

func (sd *snapshotData) resolveNodeHandle(program *compiler.Program, handle NodeHandle) (*ast.Node, error) {
	s := string(handle)
	// Format: "index.kind.path" — we need index and path, kind is informational only.
	firstDot := strings.IndexByte(s, '.')
	if firstDot == -1 {
		return nil, fmt.Errorf("%w: invalid node handle %q", ErrClientError, handle)
	}
	secondDot := strings.IndexByte(s[firstDot+1:], '.')
	if secondDot == -1 {
		return nil, fmt.Errorf("%w: invalid node handle %q", ErrClientError, handle)
	}
	secondDot += firstDot + 1 // adjust to absolute index

	idx, err := strconv.ParseUint(s[:firstDot], 10, 32)
	if err != nil {
		return nil, fmt.Errorf("%w: invalid node handle %q: %w", ErrClientError, handle, err)
	}
	path := tspath.Path(s[secondDot+1:])

	sourceFile := program.GetSourceFileByPath(path)
	if sourceFile == nil {
		return nil, fmt.Errorf("%w: node handle %q could not be resolved (file may not be loaded or handle may be stale)", ErrClientError, handle)
	}
	table := encoder.GetNodeIndexTable(sourceFile)

	if table != nil && idx < uint64(len(table.Nodes)) {
		node := table.Nodes[idx]
		if node != nil {
			return node, nil
		}
	}
	return nil, fmt.Errorf("%w: node handle %q could not be resolved (file may not be loaded or handle may be stale)", ErrClientError, handle)
}

View on GitHub (pinned to 1bcfa18d79)

When it happens

Trigger: Thrown at internal/api/session.go:3287 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of microsoft/typescript-go@1bcfa18d79 (2026-08-16). Data as JSON: /api/errors/30a11d9e4986e413. Report an issue: GitHub.