Loopback-next: Error when stopping an App that hasn't been started

Created on 29 Dec 2017  路  4Comments  路  Source: strongloop/loopback-next

Description/Steps to reproduce


While writing some tests, the cleanup code always runs await app.stop(). However if the app wasn't started, trying to stop the app throws the following error message.

TypeError: Cannot read property 'close' of undefined
    at Promise (/Users/taranveer/loopback/loopback-next/random/node_modules/@loopback/rest/dist/src/rest-server.js:417:20)
    at new Promise (<anonymous>)
    at RestServer.stop (/Users/taranveer/loopback/loopback-next/random/node_modules/@loopback/rest/dist/src/rest-server.js:416:16)
    at _forEachServer.s (/Users/taranveer/loopback/loopback-next/random/node_modules/@loopback/core/dist/src/application.js:134:42)
    at Promise.all.bindings.map (/Users/taranveer/loopback/loopback-next/random/node_modules/@loopback/core/dist/src/application.js:148:26)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
    at Function.Module.runMain (module.js:695:11)
    at startup (bootstrap_node.js:188:16)
    at bootstrap_node.js:609:3

Is this expected behaviour? Should stop catch error messages which indicate the server was never running and hence the app was successfully stopped?

Link to reproduction sandbox

Create app using lb4 app.
Create a new instance const app = new Application() ... now run app.stop() before starting it.

Expected result

Is this the designed behaviour? I think it might be more intuitive to not thrown an error if a server is already stopped. Stop should throw a error is it wasn't able to stop a server.

Acceptance Criteria

  • [ ] @loopback/rest/src/rest-server.ts has a stop method -- It shouldn't throw an error if a server can't be stopped if it was never started! -- Other error's should still be propagated.
  • [ ] Test coverage for this scenario
bug good first issue p1

Most helpful comment

I think this can be tagged with good first issue. Does anyone else agree?

All 4 comments

Discussed with @raymondfeng , the user experience can be improved here. Marking it as bug.

@virkt25 , we've identified this as DP3. Could you please add the acceptance criteria? Thanks.

Done.

I think this can be tagged with good first issue. Does anyone else agree?

Was this page helpful?
0 / 5 - 0 ratings