Skip to content

Commit

Permalink
fix(nextjs): Await Next.js server in patched getServerRequestHandler (
Browse files Browse the repository at this point in the history
  • Loading branch information
lforst committed Oct 31, 2022
1 parent 05fb78a commit 0ccb760
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/nextjs/src/utils/instrumentServer.ts
Expand Up @@ -22,6 +22,7 @@ type PlainObject<T = any> = { [key: string]: T };
// https://github.com/vercel/next.js/blob/4443d6f3d36b107e833376c2720c1e206eee720d/packages/next/server/next.ts#L32
interface NextServer {
server: Server;
getServer: () => Promise<Server>;
createServer: (options: PlainObject) => Server;
}

Expand Down Expand Up @@ -131,7 +132,7 @@ function makeWrappedHandlerGetter(origHandlerGetter: HandlerGetter): WrappedHand
const wrappedHandlerGetter = async function (this: NextServer): Promise<ReqHandler> {
if (!sdkSetupComplete) {
// stash this in the closure so that `makeWrappedReqHandler` can use it
liveServer = this.server;
liveServer = await this.getServer();
const serverPrototype = Object.getPrototypeOf(liveServer);

// Wrap for error capturing (`logError` gets called by `next` for all server-side errors)
Expand Down

0 comments on commit 0ccb760

Please sign in to comment.