Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug when trying to use vike-node prod build #2094

Open
thomasjm opened this issue Jan 20, 2025 · 2 comments
Open

Bug when trying to use vike-node prod build #2094

thomasjm opened this issue Jan 20, 2025 · 2 comments
Labels

Comments

@thomasjm
Copy link

I get the following in my console when trying to use the production version of my project. I've been trying to switch to vike-node, due to the ongoing conversation in #1165. I'm using the latest code: vike 0.4.213, vike-node 0.3.0.

entry-client-routing.dep4tC4S.js:127 Uncaught (in promise) Error: [[email protected]][Bug] You stumbled upon a Vike bug. Go to https://github.com/vikejs/vike/issues/new and copy-paste this error. A maintainer will fix the bug (usually within 24 hours).
    at createErrorWithCleanStackTrace (entry-client-routing.dep4tC4S.js:127:17)
    at assert (entry-client-routing.dep4tC4S.js:203:27)
    at getPageFilesAll (entry-client-routing.dep4tC4S.js:2538:5)
    at createPageContext (entry-client-routing.dep4tC4S.js:3013:46)
    at getPageContextBegin (entry-client-routing.dep4tC4S.js:4469:31)
    at renderPageNominal (entry-client-routing.dep4tC4S.js:4344:31)
    at renderPageClientSide (entry-client-routing.dep4tC4S.js:4338:9)
    at renderFirstPage (entry-client-routing.dep4tC4S.js:4910:11)
    at initClientRouter (entry-client-routing.dep4tC4S.js:4900:36)
    at entry-client-routing.dep4tC4S.js:4927:1

It crashes on the final assert in this function. All three of the variables in the expression are undefined: pageFilesAll, pageConfigs, and pageConfigGlobal.

async function getPageFilesAll(isClientSide, isProduction) {
    {
        assert(!globalObject$7.pageFilesGetter);
        assert(isProduction === undefined);
    }
    const { pageFilesAll, pageConfigs, pageConfigGlobal } = globalObject$7;
    assert(pageFilesAll && pageConfigs && pageConfigGlobal);
    const allPageIds = getAllPageIds(pageFilesAll, pageConfigs);
    return { pageFilesAll, allPageIds, pageConfigs, pageConfigGlobal };
}

It works okay in dev and builds without issues.

I'm not sure how to debug this. The main thing that's unusual about my setup is that I construct a GraphQL client (urql) in the pageContext callback, like this:

import vike from "vike-node/express";
...
  app.use(vike({
    pageContext(runtime: any) { // RuntimeAdapter
      const req = runtime.req;

      const [client, ssr] = makeServerUrqlClient(req.headers["cookie"], serverHost, serverPort);

      return {
        urlOriginal: req.originalUrl,
        headersOriginal: req.headers,
        universalCookies: req["universalCookies"],
        urqlClient: client,
        urqlSSR: ssr,
        isTest: process.env.IS_TEST,
      };
    },
  }));
...
@brillout
Copy link
Member

We're actually refactoring this area as we speak. ETA today/tomorrow.

@brillout
Copy link
Member

ETA today/tomorrow.

ETA this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants