diff --git a/app/srv/ws/sync/editor/code/build-code.ts b/app/srv/ws/sync/editor/code/build-code.ts index 80674bf5..b65fcacc 100644 --- a/app/srv/ws/sync/editor/code/build-code.ts +++ b/app/srv/ws/sync/editor/code/build-code.ts @@ -146,6 +146,12 @@ if (typeof global.server_hook === "function") { setup(setup) { const reinit = () => { setup.onEnd((res) => { + if (res.errors.length > 0) { + Bun.write( + Bun.file(code.path(id_site, "site", "src", "server.log")), + JSON.stringify(res.errors, null, 2) + ); + } server.init(id_site); }); }; diff --git a/app/srv/ws/sync/editor/code/server-main.ts b/app/srv/ws/sync/editor/code/server-main.ts index b219b984..9fba86d7 100644 --- a/app/srv/ws/sync/editor/code/server-main.ts +++ b/app/srv/ws/sync/editor/code/server-main.ts @@ -46,16 +46,16 @@ const serverMain = () => ({ if (typeof svr.server.init === "function") { svr.server.init({}); } - } - Bun.write( - Bun.file(code.path(site_id, "site", "src", "server.log")), - "" - ); + Bun.write( + Bun.file(code.path(site_id, "site", "src", "server.log")), + "" + ); + } } catch (e) { console.log(`Failed to init server ${site_id}`, e); } - }, 100); + }, 10); }, async http( site_id: string, @@ -64,6 +64,7 @@ const serverMain = () => ({ if (!code.esbuild[site_id]) { await codeBuild(site_id); } + if (typeof this.handler[site_id] === "undefined") { if ( await existsAsync(code.path(site_id, "server", "build", "index.js")) @@ -73,6 +74,7 @@ const serverMain = () => ({ } } const handler = this.handler[site_id]; + if (handler) { if (!handler.site_id) handler.site_id = site_id;