Skip to content

Commit

Permalink
fix: build data (critical issue with non-nodejs envs) (#1179)
Browse files Browse the repository at this point in the history
This is to fix a critical bug:
https://github.com/dai-shi/waku/pull/1066/files#r1924645235
The bug exists between v0.21.9 and v0.21.16.

Related with #1178.
This should fix the issue, but no way for automate tests for now.
(I'll revisit buildData entirely in the next PR.)

---------

Co-authored-by: Tyler <[email protected]>
  • Loading branch information
dai-shi and tylersayshi authored Jan 22, 2025
1 parent 52d8e3e commit d02a334
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/waku/src/lib/middleware/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ReactNode } from 'react';

import { resolveConfig, extractPureConfig } from '../config.js';
import type { PureConfig } from '../config.js';
import { setAllEnvInternal } from '../../server.js';
import { setAllEnvInternal, unstable_getPlatformObject } from '../../server.js';
import type { HandleRequest, HandlerRes } from '../types.js';
import type { Middleware, HandlerContext } from './types.js';
import { renderRsc, decodeBody, decodePostAction } from '../renderers/rsc.js';
Expand Down Expand Up @@ -75,9 +75,12 @@ export const handler: Middleware = (options) => {
: ('Error: loadEntries are not available' as never);
const configPromise =
options.cmd === 'start'
? entriesPromise.then((entries) =>
entries.loadConfig().then((config) => resolveConfig(config)),
)
? entriesPromise.then(async (entries) => {
if (entries.buildData) {
unstable_getPlatformObject().buildData = entries.buildData;
}
return resolveConfig(await entries.loadConfig());
})
: resolveConfig(options.config);

return async (ctx, next) => {
Expand Down

0 comments on commit d02a334

Please sign in to comment.