Skip to content

Commit

Permalink
fix: avoid non-stringify error
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Jan 21, 2025
1 parent ef52f24 commit 95e1a73
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/lifecycle.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assert from 'node:assert';
import { EventEmitter } from 'node:events';
import { debuglog } from 'node:util';
import { debuglog, format } from 'node:util';
import { isClass } from 'is-type-of';
import { Ready as ReadyObject } from 'get-ready';
import type { ReadyFunctionArg } from 'get-ready';
Expand Down Expand Up @@ -387,6 +387,10 @@ export class Lifecycle extends EventEmitter {
done();
this.timing.end(timingKey);
}, (err: Error) => {
// avoid non-stringify error: TypeError: Cannot convert object to primitive value
if (!(err instanceof Error)) {
err = new Error(format('%s', err));
}

Check warning on line 393 in src/lifecycle.ts

View check run for this annotation

Codecov / codecov/patch

src/lifecycle.ts#L392-L393

Added lines #L392 - L393 were not covered by tests
done(err);
this.timing.end(timingKey);
});
Expand Down

0 comments on commit 95e1a73

Please sign in to comment.