Skip to content

Commit fa25d57

Browse files
authored
fix: avoid non-stringify error (#289)
1 parent ef52f24 commit fa25d57

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/lifecycle.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import assert from 'node:assert';
22
import { EventEmitter } from 'node:events';
3-
import { debuglog } from 'node:util';
3+
import { debuglog, format } from 'node:util';
44
import { isClass } from 'is-type-of';
55
import { Ready as ReadyObject } from 'get-ready';
66
import type { ReadyFunctionArg } from 'get-ready';
@@ -387,6 +387,10 @@ export class Lifecycle extends EventEmitter {
387387
done();
388388
this.timing.end(timingKey);
389389
}, (err: Error) => {
390+
// avoid non-stringify error: TypeError: Cannot convert object to primitive value
391+
if (!(err instanceof Error)) {
392+
err = new Error(format('%s', err));
393+
}
390394
done(err);
391395
this.timing.end(timingKey);
392396
});

0 commit comments

Comments
 (0)