AbortSignal rejects with Code.Internal instead of Code.Canceled
Describe the bug
It seems to me that if I use AbortSignal.timeout(), then the call should end with the error canceled/deadline, not internal.
To Reproduce
client.method(msg, {signal: AbortSignal.timeout(0)})
// ConnectError: [internal] The operation was aborted due to timeout. code: 13
Environment (please complete the following information):
- @connectrpc/connect-node version: 2.0.2
- Node.js version: v22.14.0
** connect source codes
/**
* An optional AbortSignal to cancel the call.
* If cancelled, an error with Code.Canceled is raised.
*/
signal?: AbortSignal;
Missing handling TimeoutError in ConnectError.from
ConnectError.from(reason, code)
#1454
It's very unfortunate that AbortSignal.timeout doesn't provide access to the remaining time. A gRPC / Connect deadline is typically set on the client and sent to the server in a request header, so that deadlines can be propagated. Both server and client will error with deadline_exceeded. I'd recommend to use the timeoutMs client option instead of AbortSignal.timeout if possible.
This behavior however still looks like a bug that should be fixed:
client.method(msg, {signal: AbortSignal.timeout(0)}) // ConnectError: [internal] The operation was aborted due to timeout. code: 13
Because of the specific behavior of deadlines, I believe that the error should be canceled, notdeadline_exceeded. (See Error Codes in the Connect Protocol.)
Let me double check.
Yes, we have to use code canceled for TimeoutError.
Implemented in https://github.com/connectrpc/connect-es/pull/1526.