yeow-api 0.2.28 → 0.2.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/task.ts +6 -2
package/package.json
CHANGED
package/src/task.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
export function post(type: string, params: Record<string, unknown> = {}, priority?: string): Promise<unknown> {
|
|
2
2
|
return new Promise((resolve, reject) => {
|
|
3
3
|
const cbId = (globalThis as any)._registerCallback((result: any) => {
|
|
4
|
-
if (result?.err)
|
|
5
|
-
|
|
4
|
+
if (result?.err) {
|
|
5
|
+
const e = new Error(result.err);
|
|
6
|
+
const regStack = typeof (globalThis as any)._getCurrentCbStack === 'function' ? (globalThis as any)._getCurrentCbStack() : null;
|
|
7
|
+
if (regStack) e.stack += ' --- cb registered at ---\n' + regStack;
|
|
8
|
+
reject(e);
|
|
9
|
+
} else resolve(result);
|
|
6
10
|
});
|
|
7
11
|
const pld: Record<string, unknown> = { type, params, cb: cbId };
|
|
8
12
|
if (priority) pld.priority = priority;
|