Skip to content

Commit c88f5d4

Browse files
fix async timing issue with gasket data & app router
1 parent 41e5c6d commit c88f5d4

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

packages/gasket-nextjs/lib/layout/with-gasket-data.js

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ function lookupIndex(bodyChildren, index = -1) {
2929
export function withGasketData(gasket, options = { index: -1 }) {
3030
const { index } = options;
3131
return layout => async props => {
32+
await gasket.isReady;
3233
const req = await request();
3334
const gasketData = req ? await gasket.actions.getPublicGasketData?.(req) ?? {} : {};
3435
const html = await layout({ ...props });

packages/gasket-nextjs/test/layout/with-gasket-data.test.js

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ describe('withGasketData', () => {
1515
beforeEach(async () => {
1616
mockPublicGasketData = { foo: 'bar' };
1717
mockGasket = {
18+
isReady: new Promise(resolve => resolve()),
1819
actions: {
1920
getPublicGasketData: jest.fn(() => mockPublicGasketData)
2021
}

0 commit comments

Comments
 (0)