Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
NotArandomGUY committed Jun 10, 2024
1 parent add173e commit d21b28c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
7 changes: 6 additions & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,12 @@ export default class Server {
await this.runShutdownTasks()
await waitMs(delay)

await detachedSpawn(execPath, ['--security-revert=CVE-2023-46809', ...process.argv.slice(1)])
const isPkg = __filename.indexOf('mainEntry.js') !== -1
if (isPkg) {
await detachedSpawn(execPath, [...process.argv.slice(1)])
} else {
await detachedSpawn(execPath, ['--security-revert=CVE-2023-46809', ...process.argv.slice(1)])
}
exit()
}

Expand Down
23 changes: 14 additions & 9 deletions src/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ export default class Update {
await this.server.runShutdownTasks(true)

logger.info('message.update.info.restart')
await detachedSpawn(path, ['--security-revert=CVE-2023-46809', process.argv[1], ...args])
const isPkg = __filename.indexOf('mainEntry.js') !== -1
if (isPkg) {
await detachedSpawn(path, [process.argv[1], ...args])
} else {
await detachedSpawn(path, ['--security-revert=CVE-2023-46809', process.argv[1], ...args])
}

logger.info('message.update.info.exit')
proc.exit()
Expand Down Expand Up @@ -112,13 +117,13 @@ export default class Update {
// Consume response data to free up memory
res.resume()

return reject(`HTTP ${statusCode}`)
return reject(new Error(`HTTP ${statusCode}`))
}

let resData = ''

res.setEncoding('utf8')
res.on('error', err => reject(`Error: ${err.message}`))
res.on('error', err => reject(new Error(`Error: ${err.message}`)))
res.on('data', chunk => resData += chunk)
res.on('end', async () => {
try {
Expand All @@ -131,10 +136,10 @@ export default class Update {

resolve((<UpdateContent>data).v)
} catch (err) {
reject(err)
reject(<Error>err)
}
})
}).on('error', err => reject(`Error: ${err.message}`))
}).on('error', err => reject(new Error(`Error: ${err.message}`)))
})
}

Expand All @@ -146,13 +151,13 @@ export default class Update {
// Consume response data to free up memory
res.resume()

return reject(`HTTP ${statusCode}`)
return reject(new Error(`HTTP ${statusCode}`))
}

let resData = ''

res.setEncoding('utf8')
res.on('error', err => reject(`Error: ${err.message}`))
res.on('error', err => reject(new Error(`Error: ${err.message}`)))
res.on('data', chunk => resData += chunk)
res.on('end', async () => {
try {
Expand All @@ -165,10 +170,10 @@ export default class Update {

resolve(await this.decodeContent(<UpdateContent>data))
} catch (err) {
reject(err)
reject(<Error>err)
}
})
}).on('error', err => reject(`Error: ${err.message}`))
}).on('error', err => reject(new Error(`Error: ${err.message}`)))
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/webServer/handlers/WebstaticSea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class WebstaticSeaHandler extends Handler {
join(fsDir, reqPath, 'index.html')
]

const isPkg = __filename.indexOf('index.js') !== -1
const isPkg = __filename.indexOf('mainEntry.js') !== -1

if (isPkg) {
const pkgDir = join(__dirname, '../webstaticSea')
Expand Down

0 comments on commit d21b28c

Please sign in to comment.