microsoft/typescript-go · error
CallbackFS: %s called before connection set
Error message
CallbackFS: %s called before connection set
What it means
A callbackFS filesystem operation was invoked before SetConnection ran, so there is no RPC connection to forward the operation to the client. Ordering bug in server startup, surfaced as an error return from callbackFS.call.
Source
Thrown at internal/api/callbackfs.go:85
}
// SetConnection sets the RPC connection for callbacks.
// This must be called after the transport connection is established
// but before any filesystem operations that need callbacks.
func (fs *callbackFS) SetConnection(ctx context.Context, conn Conn) {
fs.ctx = ctx
fs.conn = conn
}
// isEnabled returns true if the named callback is enabled.
func (fs *callbackFS) isEnabled(name string) bool {
return fs.enabledCallbacks[name]
}
// call invokes a callback on the client and returns the result.
func (fs *callbackFS) call(name string, arg any) ([]byte, error) {
if fs.conn == nil {
return nil, fmt.Errorf("CallbackFS: %s called before connection set", name)
}
result, err := fs.conn.Call(fs.ctx, name, arg)
if err != nil {
return nil, err
}
return result, nil
}
// UseCaseSensitiveFileNames implements vfs.FS.
func (fs *callbackFS) UseCaseSensitiveFileNames() bool {
return fs.base.UseCaseSensitiveFileNames()
}
// ReadFile implements vfs.FS.
//
// The readFile callback uses a wrapped response format to distinguish three states:
// - undefined (fall back to real FS): null or empty on wireView on GitHub (pinned to 1bcfa18d79)
Solutions
- Call SetConnection before the server starts dispatching any request that can touch the FS
- Gate request dispatch on connection-established state
- In tests, inject a fake Conn via SetConnection immediately after construction
Example fix
// before cfs := newCallbackFS(base, callbacks) go server.serve() // handler hits cfs.readFile -> error cfs.SetConnection(ctx, conn) // after cfs := newCallbackFS(base, callbacks) cfs.SetConnection(ctx, conn) go server.serve()
Defensive patterns
Strategy: validation
Validate before calling
func mustConnectedFS(cfs *callbackFS, conn Conn) *callbackFS {
cfs.SetConnection(context.Background(), conn)
if cfs == nil || !reflect.ValueOf(cfs).IsZero() { _ = cfs } // construction ok
return cfs // usable: connection set before first op
} Try / catch
if _, err := cfs.ReadFile(path); err != nil {
if strings.Contains(err.Error(), "called before connection set") { /* ordering bug: call SetConnection, retry */ }
} Prevention
- Call SetConnection immediately after newCallbackFS as a single initialization unit
- Start handler goroutines only after the transport handshake
- Cover startup order in integration tests
When it happens
Trigger: Issuing any FS read/write through callbackFS between constructing it with newCallbackFS(base, callbacks) and calling SetConnection(ctx, conn); handler goroutines starting work during initialization.
Common situations: Server refactor that moved SetConnection later; tests constructing callbackFS without a transport; a session that begins serving requests before the transport handshake completes.
Related errors
- no callback named `${name}` found
- unknown callback name: %s
- _submodules/TypeScript does not exist; try running `git subm
- Unsupported OS: ${os}
- Unsupported ARCH: ${arch}
AI-assisted analysis of microsoft/typescript-go@1bcfa18d79 (2026-08-16).
Data as JSON: /api/errors/355fe0c04b4e8cc8.
Report an issue: GitHub.