apollo-server: Runtime.UnhandledPromiseRejection, Error: called start() with surprising state invoking serverWillStart
This is a very strange behavior indeed. We just started seeing this in our GQL stack this morning. I’ve reset out development environment to our stable branch to ensure that this is not related to a recent code change we have made, but the problem persists. I have been unable to find the source of this issue, and has left me quite befuddled.
{
"errorType": "Runtime.UnhandledPromiseRejection",
"errorMessage": "Error: called start() with surprising state invoking serverWillStart",
"reason": {
"errorType": "Error",
"errorMessage": "called start() with surprising state invoking serverWillStart",
"stack": [
"Error: called start() with surprising state invoking serverWillStart",
" at ApolloServer.<anonymous> (/var/task/node_modules/apollo-server-core/dist/ApolloServer.js:230:23)",
" at Generator.next (<anonymous>)",
" at /var/task/node_modules/apollo-server-core/dist/ApolloServer.js:8:71",
" at new Promise (<anonymous>)",
" at __awaiter (/var/task/node_modules/apollo-server-core/dist/ApolloServer.js:4:12)",
" at ApolloServer._start (/var/task/node_modules/apollo-server-core/dist/ApolloServer.js:226:16)",
" at ApolloServer.<anonymous> (/var/task/node_modules/apollo-server-core/dist/ApolloServer.js:280:22)",
" at Generator.next (<anonymous>)",
" at /var/task/node_modules/apollo-server-core/dist/ApolloServer.js:8:71",
" at new Promise (<anonymous>)"
]
},
"promise": {},
"stack": [
"Runtime.UnhandledPromiseRejection: Error: called start() with surprising state invoking serverWillStart",
" at process.on (/var/runtime/index.js:37:15)",
" at process.emit (events.js:203:15)",
" at process.EventEmitter.emit (domain.js:448:20)",
" at emitPromiseRejectionWarnings (internal/process/promises.js:140:18)",
" at process._tickCallback (internal/process/next_tick.js:69:34)"
]
}
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 17 (9 by maintainers)
Hi also got this problem using
apollo-server-micro
insider a nextjs fullstack app, I solved it by just storing theserver.start()
function in a constant like thisconst startServer = server.start()
and then using it inside the default export of the cors function@dep-dt Ah, you didn’t mention in the first message that you’re using Lambda. Yeah, combining
apollo-server-core
v2.22.0 or v2.22.1 with olderapollo-server-lambda
was definitely 100% unusable. v2.22.2 should fix this (as should upgradingapollo-server-lambda
).Thanks for the replies. I did an update of
apollo-server
from2.21.0
to2.22.1
and this seems to have fixed it! 👍🏻 I’ll definitely look in to usingpackage-lock.json
in the future, too.