Skip to content

Commit b98922d

Browse files
Andreytshemsedinov
andauthored
Fix proc timeout reached error detection
Refs: metarhia/metautil#195 Co-authored-by: Timur Shemsedinov <timur.shemsedinov@gmail.com> PR-URL: #464
1 parent 5391704 commit b98922d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/server.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,10 @@ class Server {
266266
try {
267267
result = await proc.invoke(context, args);
268268
} catch (error) {
269-
if (error.message === 'Timeout reached') {
270-
error.code = error.httpCode = 408;
271-
}
272-
return void client.error(error.code, { id, error });
269+
let code = error.code === 'ETIMEOUT' ? 408 : 500;
270+
if (typeof error.code === 'number') code = error.code;
271+
error.httpCode = code;
272+
return void client.error(code, { id, error });
273273
} finally {
274274
proc.leave();
275275
}

0 commit comments

Comments
 (0)