Skip to content

Commit

Permalink
fix: server crashes on missing module (#2089)
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-jan authored Feb 19, 2024
1 parent 780f957 commit e8f5c22
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
15 changes: 7 additions & 8 deletions core/src/node/api/restful/helper/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,6 @@ export const chatCompletions = async (request: any, reply: any) => {
apiUrl = engineConfiguration.full_url
}

reply.raw.writeHead(200, {
'Content-Type': 'text/event-stream',
'Cache-Control': 'no-cache',
'Connection': 'keep-alive',
'Access-Control-Allow-Origin': '*',
})

const headers: Record<string, any> = {
'Content-Type': 'application/json',
}
Expand All @@ -343,8 +336,14 @@ export const chatCompletions = async (request: any, reply: any) => {
})
if (response.status !== 200) {
console.error(response)
return
reply.code(400).send(response)
} else {
reply.raw.writeHead(200, {
'Content-Type': 'text/event-stream',
'Cache-Control': 'no-cache',
'Connection': 'keep-alive',
'Access-Control-Allow-Origin': '*',
})
response.body.pipe(reply.raw)
}
}
9 changes: 5 additions & 4 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,20 @@
"@npmcli/arborist": "^7.3.1",
"dotenv": "^16.3.1",
"fastify": "^4.24.3",
"request": "^2.88.2",
"fetch-retry": "^5.0.6",
"tcp-port-used": "^1.0.2",
"request-progress": "^3.0.0"
"node-fetch": "2",
"request": "^2.88.2",
"request-progress": "^3.0.0",
"tcp-port-used": "^1.0.2"
},
"devDependencies": {
"@types/body-parser": "^1.19.5",
"@types/npmcli__arborist": "^5.6.4",
"@types/tcp-port-used": "^1.0.4",
"@typescript-eslint/eslint-plugin": "^6.7.3",
"@typescript-eslint/parser": "^6.7.3",
"eslint-plugin-react": "^7.33.2",
"run-script-os": "^1.1.6",
"@types/tcp-port-used": "^1.0.4",
"typescript": "^5.2.2"
}
}

0 comments on commit e8f5c22

Please sign in to comment.