From c5b1580f918473a4b585724c9a3ac4dd6f8c26a0 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Wed, 19 Oct 2022 17:56:46 +0200 Subject: [PATCH] Remove custom digest support. Take into account stack --- packages/next/server/app-render.tsx | 6 +---- test/e2e/app-dir/index.test.ts | 38 ++--------------------------- 2 files changed, 3 insertions(+), 41 deletions(-) diff --git a/packages/next/server/app-render.tsx b/packages/next/server/app-render.tsx index 1da8c16eda666..7846bbb36f6f7 100644 --- a/packages/next/server/app-render.tsx +++ b/packages/next/server/app-render.tsx @@ -190,12 +190,8 @@ function createErrorHandler( // console.error(_source, err) console.error(err) capturedErrors.push(err) - if (err.digest) { - return err.digest - } - // TODO-APP: look at using webcrypto instead. Requires a promise to be awaited. - return stringHash(err.message).toString() + return stringHash(err.message + err.stack + (err.digest || '')).toString() } } diff --git a/test/e2e/app-dir/index.test.ts b/test/e2e/app-dir/index.test.ts index fb5ec766d1c00..cc6b318efe65b 100644 --- a/test/e2e/app-dir/index.test.ts +++ b/test/e2e/app-dir/index.test.ts @@ -1578,7 +1578,7 @@ describe('app dir', () => { expect( await browser.waitForElementByCss('#error-boundary-digest').text() // Digest of the error message should be stable. - ).toBe('2397877870') + ).not.toBe('') // TODO-APP: ensure error overlay is shown for errors that happened before/during hydration // expect(await hasRedbox(browser)).toBe(true) // expect(await getRedboxHeader(browser)).toMatch(/this is a test/) @@ -1592,41 +1592,7 @@ describe('app dir', () => { expect( await browser.waitForElementByCss('#error-boundary-digest').text() // Digest of the error message should be stable. - ).toBe('2397877870') - } - }) - - it('should trigger error component when an error with custom digest happens during server components rendering', async () => { - const browser = await webdriver( - next.url, - '/error/server-component/custom-digest' - ) - - if (isDev) { - expect( - await browser - .waitForElementByCss('#error-boundary-message') - .elementByCss('#error-boundary-message') - .text() - ).toBe('this is a test') - expect( - await browser.waitForElementByCss('#error-boundary-digest').text() - // Digest of the error message should be stable. - ).toBe('custom') - // TODO-APP: ensure error overlay is shown for errors that happened before/during hydration - // expect(await hasRedbox(browser)).toBe(true) - // expect(await getRedboxHeader(browser)).toMatch(/this is a test/) - } else { - await browser - expect( - await browser.waitForElementByCss('#error-boundary-message').text() - ).toBe( - 'An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.' - ) - expect( - await browser.waitForElementByCss('#error-boundary-digest').text() - // Digest of the error message should be stable. - ).toBe('custom') + ).not.toBe('') } })