fix: top-level try/catch around connect() with stack trace
The schema fix to use uint32 for status was the right call, but the error persists. The fact that the raw bytes are being printed means the new code IS running, but the error must be coming from somewhere outside the inline try/catch blocks. Wrapping the whole connect() in a safety net so we'll see a stack trace on the next run and can pinpoint the exact line.
This commit is contained in:
@@ -84,6 +84,19 @@ export class KRPCClient {
|
||||
}
|
||||
|
||||
async connect(): Promise<void> {
|
||||
// Wrap EVERYTHING in a top-level try so we always get a clean
|
||||
// error message (not a buried TypeError from protobufjs
|
||||
// nested-enum resolution). The specific sub-step failures are
|
||||
// caught inline for nicer messages, but this top-level guard
|
||||
// is the safety net.
|
||||
try {
|
||||
return await this._connectImpl();
|
||||
} catch (e) {
|
||||
throw new Error(`kRPC connect failed at unknown step: ${formatErr(e)} (stack: ${e instanceof Error ? e.stack : 'n/a'})`);
|
||||
}
|
||||
}
|
||||
|
||||
private async _connectImpl(): Promise<void> {
|
||||
// RPC handshake
|
||||
try {
|
||||
this.rpcSocket = await tcpConnect(
|
||||
@@ -173,7 +186,7 @@ export class KRPCClient {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('[krpc-client] stream loop error:', err);
|
||||
});
|
||||
}
|
||||
} // end _connectImpl
|
||||
|
||||
isConnected(): boolean {
|
||||
return this.rpcSocket !== null && this.streamSocket !== null && !this.closed;
|
||||
|
||||
Reference in New Issue
Block a user