Skip to content

Conversation

0xbad0c0d3
Copy link
Contributor

@0xbad0c0d3 0xbad0c0d3 commented Sep 25, 2025

I was running tests locally and noticed that they are stays running if something wents wrong that's why I've added: 04d2fbf

fixes #17514

Is there a way to run e2e tests pipeline without merging to develop?


Note

Introduce copyExecutionContext with tests; make Cloudflare integration test runner accept AbortSignal and update tests; ignore JUnit reports.

  • Cloudflare SDK:
    • Utility: Add packages/cloudflare/src/utils/copyExecutionContext.ts to clone ExecutionContext/DurableObjectState with overridable, bound methods.
    • Tests: Add packages/cloudflare/test/copy-execution-context.test.ts covering method overriding, immutability safety, and symbol property preservation.
  • Integration Tests (Cloudflare):
    • Runner: dev-packages/cloudflare-integration-tests/runner.ts start now accepts optional AbortSignal and forwards it to spawn.
    • Suites: Update tests (basic, tracing/anthropic-ai, tracing/durableobject, tracing/openai) to pass { signal } from Vitest and call .start(signal).
  • Repo:
    • .gitignore: Ignore packages/**/*.junit.xml JUnit reports.

Written by Cursor Bugbot for commit cb97187. This will update automatically on new commits. Configure here.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@mydea
Copy link
Member

mydea commented Sep 26, 2025

You should be able to run E2E tests locally:

cd dev-packages/e2e-tests
yarn test:run test-app-name

This requires docker & pnpm to be setup!

@andreiborza
Copy link
Member

@0xbad0c0d3 is this ready for review?

@0xbad0c0d3
Copy link
Contributor Author

No, not yet, sorry for the delay.

@andreiborza
Copy link
Member

No worries, just wasn't sure :) When you're ready, please request me as a reviewer.

@0xbad0c0d3
Copy link
Contributor Author

You should be able to run E2E tests locally:

cd dev-packages/e2e-tests
yarn test:run test-app-name

This requires docker & pnpm to be setup!

and also volta

@0xbad0c0d3
Copy link
Contributor Author

@andreiborza so, it is ready

@andreiborza
Copy link
Member

Thanks! Will take a look in a bit.

@andreiborza andreiborza self-requested a review September 30, 2025 13:03
@andreiborza andreiborza requested a review from JPeer264 October 9, 2025 22:22
configurable: true,
enumerable: true,
set: newValue => {
if (typeof newValue !== 'function') throw new Error('Cannot override non-function');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

h: I don't think that throwing an error is the right choice here since it could fail the entire call.
I'd be nice if there is a way to pass

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

h: I don't think that throwing an error is the right choice here since it could fail the entire call. I'd be nice if there is a way to pass

I was thinking of it, but then decided to do this way because I am checking the type before overriding and expecting overriding only callable objects. If, for some reason, function will be attempted to be overridden by non-function - the app will fail later, without the check. But it will fail.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would assume you mean it would fail on Cloudflare itself not on the SDK level, right? I couldn't think of a use case where it would make sense to fail right here. return false would be sufficient as well if I am not mistaken.

In the getter we will anyways return the "methodFunction", so I think it is safe to not error out here

@andreiborza any thoughts on this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would assume you mean it would fail on Cloudflare itself not on the SDK level, right? I couldn't think of a use case where it would make sense to fail right here. return false would be sufficient as well if I am not mistaken.

In the getter we will anyways return the "methodFunction", so I think it is safe to not error out here

@andreiborza any thoughts on this?

return false is redundant and I removed this. But, anyway, I would agree with you after a bit more thinking. Why? Because we should not "brake" expected behaviour and if someone wants to set non-function to a method - it is not our concern to "prevent" of doing such. So, yes. I am going to remove error throwing here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, definitely agree. Good catch @JPeer264 😄

@JPeer264
Copy link
Member

Thanks a lot for creating a PR. I added two notes

cursor[bot]

This comment was marked as outdated.

cod1k added 7 commits October 13, 2025 10:23
Updated test definitions across multiple suites to accept and pass abort signals (`signal`) for enhanced request handling. Adjusted the `start` method in the test runner to support optional abort signals.
Reworked `copyExecutionContext` to use a dynamic property descriptor approach, enabling method overrides without altering the original object. Expanded test cases to cover additional methods and verify override behavior.
Enhanced the descriptor logic to better handle non-function properties and prevent invalid method overrides. Fixed potential issues with binding non-function properties to the context.
Updated the `OverridesStore` type to strictly associate keys with context-specific methods, improving type safety. Renamed and enhanced the descriptor creation function to better handle method overriding and added checks for function-only properties.
Added `packages/**/*.junit.xml` to `.gitignore` to prevent JUnit report files from being tracked in the repository, keeping the working directory clean and avoiding unnecessary versioning of test artifacts.
Replaced direct usage of `ExecutionContext` with `copyExecutionContext` for consistency and improved flexibility. Applied changes across handlers, durable objects, and workflows to enhance context management and method overriding.
@JPeer264 JPeer264 changed the title Fix/17514 fix(cloudflare): copy execution context in durable objects and handlers Oct 15, 2025
Copy link
Member

@JPeer264 JPeer264 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Waiting for @andreiborza for a second pair of eyes.

const [event, env, context] = args;
const [event, env, ctx] = args;
const context = copyExecutionContext(ctx);
args[2] = context;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just leaving a note here for the record. Here we mutate the actual args directly and is often not safe to use, but since we are inside a Proxy it is fine and also a bit faster :)

@JPeer264 JPeer264 merged commit 6230aed into getsentry:develop Oct 16, 2025
67 of 69 checks passed
@JPeer264
Copy link
Member

Thanks again @0xbad0c0d3 for your contribution 🥳

andreiborza pushed a commit that referenced this pull request Oct 16, 2025
This PR adds the external contributor to the CHANGELOG.md file, so that
they are credited for their contribution. See #17786

Co-authored-by: JPeer264 <10677263+JPeer264@users.noreply.github.com>
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.

@sentry/cloudflare crashes DurableObjects due to unsafe & unnecessary proxying of waitUntil()

4 participants