Skip to content

Commit

Permalink
Fix proc timeout reached error detection
Browse files Browse the repository at this point in the history
Refs: metarhia/metautil#195
Co-authored-by: Timur Shemsedinov <[email protected]>
PR-URL: #464
  • Loading branch information
aliendrew and tshemsedinov authored Oct 21, 2023
1 parent 5391704 commit b98922d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,10 @@ class Server {
try {
result = await proc.invoke(context, args);
} catch (error) {
if (error.message === 'Timeout reached') {
error.code = error.httpCode = 408;
}
return void client.error(error.code, { id, error });
let code = error.code === 'ETIMEOUT' ? 408 : 500;
if (typeof error.code === 'number') code = error.code;
error.httpCode = code;
return void client.error(code, { id, error });
} finally {
proc.leave();
}
Expand Down

0 comments on commit b98922d

Please sign in to comment.