Skip to content

Comments

fix: reject cy.intercept delay values >= 2^31#33377

Open
veeceey wants to merge 5 commits intocypress-io:developfrom
veeceey:fix/issue-33183-intercept-delay-overflow
Open

fix: reject cy.intercept delay values >= 2^31#33377
veeceey wants to merge 5 commits intocypress-io:developfrom
veeceey:fix/issue-33183-intercept-delay-overflow

Conversation

@veeceey
Copy link

@veeceey veeceey commented Feb 14, 2026

Problem

When cy.intercept is used with a delay value >= 2^31 (2147483647ms, ~24.8 days), the delay is silently ignored because setTimeout uses a signed 32-bit integer internally. Node.js coerces values >= 2^31 to 1ms, so the response is sent immediately instead of being delayed.

While nobody probably needs a 24-day delay, this is confusing for anyone using very large values (like Number.MAX_SAFE_INTEGER) to effectively "pause" a response indefinitely during testing.

Fix

Added validation in validateStaticResponse to throw a clear error when delay >= 2147483647. This is consistent with how throttleKbps already gets validated.

The error message explains the limitation:

`delay` must be less than 2147483647ms (approximately 24.8 days).
Larger values are silently ignored by the timer implementation.

Testing

Added a test case to the existing with invalid StaticResponse test suite that verifies the error is thrown when delay exceeds the maximum.

Fixes #33183

@CLAassistant
Copy link

CLAassistant commented Feb 14, 2026

CLA assistant check
All committers have signed the CLA.

@cypress-app-bot
Copy link
Collaborator

@jennifer-shehane
Copy link
Member

@veeceey Thanks for the contribution! Could you please sign our CLA?

@veeceey
Copy link
Author

veeceey commented Feb 16, 2026

Hi @jennifer-shehane, thanks for the heads up! I've just signed the CLA — could you trigger a recheck when you get a chance? Let me know if there's anything else needed.

@jennifer-shehane
Copy link
Member

@veeceey The CLA is still not showing up as signed. I triggered a recheck.

Sometimes the author of the commits does not match the email address on your GitHub account. Our CLA bot gets confused when they don't match - I'm not sure if that's what's happening here. Here are some solutions to fixing when commits are linked to the wrong user: https://help.github.com/articles/why-are-my-commits-linked-to-the-wrong-user/

@veeceey
Copy link
Author

veeceey commented Feb 16, 2026

Hey @jennifer-shehane, thanks for the recheck! I've verified the commits are authored with varun_6april@hotmail.com which is associated with my GitHub account. I tried signing the CLA again through the link — could you try one more recheck? If it still doesn't work, I can try amending the commits with my noreply GitHub email instead.

@veeceey
Copy link
Author

veeceey commented Feb 16, 2026

recheck

@MikeMcC399
Copy link
Contributor

2^31 isn't recognized in JavaScript as meaning 2 to the power of 31, although it is correct in Microsoft Excel.

@veeceey veeceey force-pushed the fix/issue-33183-intercept-delay-overflow branch from 7bbd904 to b76a958 Compare February 16, 2026 21:13
@veeceey
Copy link
Author

veeceey commented Feb 16, 2026

Good catch on the notation! The 2^31 in the title and comments is just mathematical shorthand for "2 to the power of 31" — the actual code uses the numeric literal 2147483647 (and the comment says 2^31 - 1). No 2^31 or 2**31 expressions in the executable code paths. I've also rebased on the latest develop to resolve the merge conflicts.

…ser and can complete (cypress-io#33366)

* fix: login attempts subsequent to a cancelled one now launch the browser and can complete

* resolve cached responses with a bluebird promise instead of a native promise

* adds typedefs for @cypress/request and extends interfaces so that api/index.ts can be better typed

* correct type declaration in packages/server/lib/cloud/user.ts

* clean up ts/package.json

* changelog

* rm expect-error directive and repalce with ignore - why is driver typechecking this?

* changelog
setTimeout uses a signed 32-bit integer internally, so delay values
>= 2^31 (~24.8 days) are silently coerced to 1ms. This causes the
delay to be effectively ignored with no indication to the user.

Add validation in validateStaticResponse to throw a clear error
when delay >= 2^31, consistent with how throttleKbps is validated.

Fixes cypress-io#33183
- Add changelog entry for delay validation to cli/CHANGELOG.md
- Fix padding-line-between-statements lint error (blank line after const)
@veeceey veeceey force-pushed the fix/issue-33183-intercept-delay-overflow branch from b76a958 to b453d42 Compare February 17, 2026 08:51
@cacieprins cacieprins self-requested a review February 17, 2026 15:23
@cacieprins cacieprins self-assigned this Feb 17, 2026
@veeceey
Copy link
Author

veeceey commented Feb 18, 2026

recheck

@veeceey
Copy link
Author

veeceey commented Feb 20, 2026

Hi @jennifer-shehane -- just wanted to confirm the CLA is now showing as signed (the CLA check is passing green). The pull-request and approve-contributor-pr CircleCI checks are pending maintainer approval to run. Could you trigger those when you get a chance? Everything else is green. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cy.intercept delay is not always respected when >= 2^31

6 participants