question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Runtime.UnhandledPromiseRejection, Error: called start() with surprising state invoking serverWillStart

See original GitHub issue

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)"
    ]
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:17 (9 by maintainers)

github_iconTop GitHub Comments

7reactions
AlvaroAquijeDiazcommented, Nov 19, 2021

Hi also got this problem using apollo-server-micro insider a nextjs fullstack app, I solved it by just storing the server.start() function in a constant like this const startServer = server.start() and then using it inside the default export of the cors function

1reaction
glassercommented, Mar 31, 2021

@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 older apollo-server-lambda was definitely 100% unusable. v2.22.2 should fix this (as should upgrading apollo-server-lambda).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Migrating to Apollo Server 4 - Apollo GraphQL Docs
start() method, before validating that the server has started by calling server.assertStarted() . context initialization function. In Apollo Server 3, you could ...
Read more >
apollo-server-core - UNPKG
508, initialState.phase !== 'initialized with schema'. 509, ) {. 510, throw new Error(. 511, `called start() with surprising state ${initialState.phase}`,.
Read more >
WhatsNew 1.3 | Ktor Framework
Ktor client raises "ClosedSelectorException" instead of proper error.
Read more >
apollo-server-errors | Yarn - Package Manager
Note that to ensure you're using the appropriate version of apollo-server-env with apollo-datasource-rest , you need to be using v3.5.1 of that package....
Read more >
connect ECONNREFUSED 172.16.1.12:27017 Code Example
log error === connect ECONNREFUSED 127.0.0.1:27017 ... This happened probably because the MongoDB service isn't started. ... The server will start.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found