Skip to content

Commit b41ac43

Browse files
authored
Merge pull request #90 from Procedure-RPC/fix-call
bugfix: `call` should correctly throw ProcedureNotFoundError when endpoint is incorrect
2 parents cb5c85a + 95571ed commit b41ac43

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,16 @@ export async function call<Output = unknown>(
629629
)
630630
: ping(endpoint, opts.ping, opts.ipv6, opts.signal));
631631
} catch (error) {
632-
throw error instanceof ProcedureTimedOutError
632+
const isTimeoutError = (error: unknown): boolean =>
633+
error instanceof ProcedureTimedOutError ||
634+
(error instanceof AggregateError &&
635+
error.errors.every(
636+
(e) =>
637+
e instanceof ProcedureTimedOutError ||
638+
isTimeoutError(e)
639+
));
640+
if (!isTimeoutError(error)) console.debug(error);
641+
throw isTimeoutError(error)
633642
? new ProcedureNotFoundError() // timeout on ping = not found
634643
: error;
635644
}

0 commit comments

Comments
 (0)