mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-02 19:12:40 +08:00
fix(core): errors get swallowed if thrown inside async event functions (#10030)
This commit is contained in:
committed by
GitHub
parent
e3255c00d8
commit
bdade0f0d5
@ -294,10 +294,19 @@ export class Observable implements ObservableDefinition {
|
||||
if (entry.once) {
|
||||
observers.splice(i, 1);
|
||||
}
|
||||
|
||||
let returnValue;
|
||||
if (entry.thisArg) {
|
||||
entry.callback.apply(entry.thisArg, [data]);
|
||||
returnValue = entry.callback.apply(entry.thisArg, [data]);
|
||||
} else {
|
||||
entry.callback(data);
|
||||
returnValue = entry.callback(data);
|
||||
}
|
||||
|
||||
// This ensures errors thrown inside asynchronous functions do not get swallowed
|
||||
if (returnValue && returnValue instanceof Promise) {
|
||||
returnValue.catch((err) => {
|
||||
console.error(err);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user