We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent de26a2e commit 10f52e1Copy full SHA for 10f52e1
2 files changed
.changeset/fix-kernel-unhandled-rejection.md
@@ -0,0 +1,5 @@
1
+---
2
+"@objectstack/core": patch
3
4
+
5
+fix: silence unhandled promise rejections when checking for async services in kernel
packages/core/src/kernel.ts
@@ -94,6 +94,9 @@ export class ObjectKernel {
94
const service = this.pluginLoader.getService(name);
95
if (service instanceof Promise) {
96
// If we found it in the loader but not in the sync map, it's likely a factory-based service or still loading
97
+ // We must silence any potential rejection from this promise since we are about to throw our own error
98
+ // and abandon the promise. Without this, Node.js will crash with "Unhandled Promise Rejection".
99
+ service.catch(() => {});
100
throw new Error(`Service '${name}' is async - use await`);
101
}
102
return service as T;
0 commit comments