Skip to content

Commit

Permalink
fix: missing statusCode in PENDING over ws
Browse files Browse the repository at this point in the history
Initialise the statusCode of the request always to 202 along
with state: 'PENDING' when it is created. Remove setting the
statusCode to 202 that was only in the http put handling code
path.

Fixes #1506.
  • Loading branch information
tkurki committed Jan 2, 2023
1 parent 80aceb5 commit 54a06f8
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/put.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ function putPath(app, contextParam, path, body, req, requestId, updateCb) {
if (reply.state === 'PENDING') {
// backwards compatibility
reply.action = { href: reply.href }
reply.statusCode = 202
}
resolve(reply)
})
Expand Down
1 change: 1 addition & 0 deletions src/requestResponse.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function createRequest(app, type, clientRequest, user, clientIp, updateCb) {
ip: clientIp || undefined,
date: new Date(),
state: 'PENDING',
statusCode: 202,
updateCb: updateCb,
user: user || undefined
}
Expand Down
3 changes: 2 additions & 1 deletion test/put.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe('Put Requests', () => {
result.status.should.equal(405)
})

it('HTTP successfull put', async function () {
it('HTTP successful PUT', async function () {
let result = await fetch(
`${url}/signalk/v1/api/vessels/self/electrical/switches/switch2.state`,
{
Expand All @@ -98,6 +98,7 @@ describe('Put Requests', () => {
let response = await result.json()
response.should.have.property('state')
response.state.should.equal('PENDING')
response.statusCode.should.equal(202)
response.should.have.property('href')

await sleep(200)
Expand Down

0 comments on commit 54a06f8

Please sign in to comment.