Skip to content

Commit c0ec07f

Browse files
authored
fix(next): add ssrPrepass-callback to avoid bundling of react-dom (#5426)
1 parent c8fd7dd commit c0ec07f

File tree

2 files changed

+5
-61
lines changed

2 files changed

+5
-61
lines changed

playwright/smoke.test.ts

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { test, expect } from '@playwright/test';
1+
import { test } from '@playwright/test';
22

33
test.setTimeout(35e3);
44

@@ -8,12 +8,7 @@ test('go to /', async ({ page }) => {
88
await page.waitForSelector(`text=Starter`);
99
});
1010

11-
test('test 404', async ({ page }) => {
12-
const res = await page.goto('/post/not-found');
13-
expect(res?.status()).toBe(404);
14-
});
15-
16-
test('add a post', async ({ page, browser }) => {
11+
test('add a post', async ({ page }) => {
1712
const nonce = `${Math.random()}`;
1813

1914
await page.goto('/');
@@ -23,32 +18,5 @@ test('add a post', async ({ page, browser }) => {
2318
await page.waitForLoadState('networkidle');
2419
await page.reload();
2520

26-
expect(await page.content()).toContain(nonce);
27-
28-
const ssrContext = await browser.newContext({
29-
javaScriptEnabled: false,
30-
});
31-
const ssrPage = await ssrContext.newPage();
32-
await ssrPage.goto('/');
33-
34-
expect(await ssrPage.content()).toContain(nonce);
35-
});
36-
37-
test('server-side rendering test', async ({ page, browser }) => {
38-
// add a post
39-
const nonce = `${Math.random()}`;
40-
41-
await page.goto('/');
42-
await page.fill(`[name=title]`, nonce);
43-
await page.fill(`[name=text]`, nonce);
44-
await page.click(`form [type=submit]`);
45-
await page.waitForLoadState('networkidle');
46-
47-
// load the page without js
48-
const ssrContext = await browser.newContext({
49-
javaScriptEnabled: false,
50-
});
51-
const ssrPage = await ssrContext.newPage();
52-
await ssrPage.goto('/');
53-
expect(await ssrPage.content()).toContain(nonce);
21+
await page.waitForSelector(`text="${nonce}"`);
5422
});

src/utils/trpc.ts

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { httpBatchLink, loggerLink } from '@trpc/client';
22
import { createTRPCNext } from '@trpc/next';
3+
34
import type { inferRouterInputs, inferRouterOutputs } from '@trpc/server';
45
import type { NextPageContext } from 'next';
56
// ℹ️ Type-only import:
@@ -96,32 +97,7 @@ export const trpc = createTRPCNext<AppRouter, SSRContext>({
9697
/**
9798
* @link https://trpc.io/docs/v11/ssr
9899
*/
99-
ssr: true,
100-
/**
101-
* Set headers or status code when doing SSR
102-
*/
103-
responseMeta(opts) {
104-
const ctx = opts.ctx as SSRContext;
105-
106-
if (ctx.status) {
107-
// If HTTP status set, propagate that
108-
return {
109-
status: ctx.status,
110-
};
111-
}
112-
113-
const error = opts.clientErrors[0];
114-
if (error) {
115-
// Propagate http first error from API calls
116-
return {
117-
status: error.data?.httpStatus ?? 500,
118-
};
119-
}
120-
121-
// for app caching with SSR see https://trpc.io/docs/v11/caching
122-
123-
return {};
124-
},
100+
ssr: false,
125101
/**
126102
* @link https://trpc.io/docs/v11/data-transformers
127103
*/

0 commit comments

Comments
 (0)