microsoft/typescript-go · error · ErrClientError

%w: invalid node handle %q

Error message

%w: invalid node handle %q

What it means

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

Source

Thrown at internal/api/session.go:3277

	if err != nil {
		return nil, err
	}
	defer setup.done()

	t, err := setup.sd.resolveTypeHandle(params.Project, params.Type)
	if err != nil {
		return nil, err
	}

	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)

View on GitHub (pinned to 1bcfa18d79)

When it happens

Trigger: Thrown at internal/api/session.go:3277 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/8429ce0c3eae2f49. Report an issue: GitHub.