From d5678c794ff9a9850a968b03391b826a1389dc9c Mon Sep 17 00:00:00 2001 From: Matt Schile Date: Tue, 28 Nov 2023 09:21:06 -0700 Subject: [PATCH] fix: don't inherit default message for request logging (#28411) --- cli/CHANGELOG.md | 1 + .../cypress/e2e/cypress/proxy-logging.cy.ts | 21 +++++++++++++++++++ packages/driver/src/cypress/proxy-logging.ts | 1 + 3 files changed, 23 insertions(+) diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index a47d3f7f5789..1abf0484ba5f 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -6,6 +6,7 @@ _Released 12/5/2023 (PENDING)_ **Bugfixes:** - Fixed an issue where pages or downloads opened in a new tab were missing basic auth headers. Fixes [#28350](https://github.com/cypress-io/cypress/issues/28350). +- Fixed an issue where request logging would default the `message` to the `args` of the currently running command even though those `args` would not apply to the request log and are not displayed. If the `args` are sufficiently large (e.g. when running the `cy.task` from the [code-coverage](https://github.com/cypress-io/code-coverage/) plugin) there could be performance/memory implications. Addressed in [#28411](https://github.com/cypress-io/cypress/pull/28411). ## 13.6.0 diff --git a/packages/driver/cypress/e2e/cypress/proxy-logging.cy.ts b/packages/driver/cypress/e2e/cypress/proxy-logging.cy.ts index 21f3bfe12c49..8bfd6367e565 100644 --- a/packages/driver/cypress/e2e/cypress/proxy-logging.cy.ts +++ b/packages/driver/cypress/e2e/cypress/proxy-logging.cy.ts @@ -126,6 +126,27 @@ describe('Proxy Logging', () => { img.src = `/fixtures/media/cypress.png?${Date.now()}` }) + it('does not inherit the message of the currently running command', () => { + const logs: any[] = [] + + cy.on('log:added', (log) => { + if (log.name !== 'request') return + + logs.push(log) + }) + + // delay the fetch call by 100ms to ensure it gets + // triggered during the cy.wait() below + setTimeout(() => { + fetch('/some-url') + }, 100) + + cy.wait(200).then(() => { + expect(logs).to.have.length(1) + expect(logs[0].message).to.eq('') + }) + }) + context('with cy.intercept()', () => { it('shows non-xhr/fetch log if intercepted', (done) => { const src = `/fixtures/media/cypress.png?${Date.now()}` diff --git a/packages/driver/src/cypress/proxy-logging.ts b/packages/driver/src/cypress/proxy-logging.ts index 4536f2ba4005..1f71a718debb 100644 --- a/packages/driver/src/cypress/proxy-logging.ts +++ b/packages/driver/src/cypress/proxy-logging.ts @@ -67,6 +67,7 @@ function getRequestLogConfig (req: Omit): Partial req.consoleProps, renderProps: () => { function getIndicator (): 'aborted' | 'pending' | 'successful' | 'bad' {