fix: ext loading error second.
This commit is contained in:
parent
147547c609
commit
e63706f682
|
@ -58,7 +58,7 @@ export async function boot() {
|
|||
_status.event = lib.element.GameEvent.initialGameEvent();
|
||||
|
||||
setWindowListener();
|
||||
await setOnError();
|
||||
const promiseErrorHandler = await setOnError();
|
||||
|
||||
// 无名杀更新日志
|
||||
if (window.noname_update) {
|
||||
|
@ -478,8 +478,25 @@ export async function boot() {
|
|||
extensionsLoading.push(importExtension(name));
|
||||
}
|
||||
|
||||
await Promise.allSettled(extensionsLoading);
|
||||
await Promise.allSettled(_status.extensionLoading);
|
||||
const extErrorList = [];
|
||||
for (const promise of extensionsLoading) {
|
||||
await promise.catch(async (error) => {
|
||||
extErrorList.add(error);
|
||||
if (!promiseErrorHandler || !promiseErrorHandler.onHandle) return;
|
||||
// @ts-ignore
|
||||
await promiseErrorHandler.onHandle({ promise });
|
||||
});
|
||||
}
|
||||
for (const promise of _status.extensionLoading) {
|
||||
await promise.catch(async (error) => {
|
||||
if (extErrorList.includes(error)) return;
|
||||
if (!promiseErrorHandler || !promiseErrorHandler.onHandle) return;
|
||||
// @ts-ignore
|
||||
await promiseErrorHandler.onHandle({ promise });
|
||||
});
|
||||
}
|
||||
// await Promise.allSettled(_status.extensionLoading);
|
||||
|
||||
_status.extensionLoaded.filter(Boolean).forEach((name) => {
|
||||
lib.announce.publish("Noname.Init.Extension.onLoad", name);
|
||||
lib.announce.publish(`Noname.Init.Extension.${name}.onLoad`, void 0);
|
||||
|
@ -868,6 +885,8 @@ async function setOnError() {
|
|||
game.loop();
|
||||
}
|
||||
};
|
||||
|
||||
return promiseErrorHandler;
|
||||
}
|
||||
|
||||
function setWindowListener() {
|
||||
|
|
|
@ -60,6 +60,7 @@ export class ChromePromiseErrorHandler {
|
|||
*/
|
||||
onHandle(event) {
|
||||
event.promise.catch((error) => {
|
||||
console.error(error)
|
||||
const result = this.#errorList.find(savedError => savedError[0] === error);
|
||||
if (result) {
|
||||
// @ts-ignore
|
||||
|
|
Loading…
Reference in New Issue