Skip to content

Conversation

@deathbyknowledge
Copy link

Adds a Props type parameter to the ExportedHandler types for ExecutionContext.

More context cloudflare/agents#501

@deathbyknowledge deathbyknowledge requested review from a team as code owners January 29, 2026 11:17
@github-actions
Copy link

github-actions bot commented Jan 29, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@deathbyknowledge
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 29, 2026

Merging this PR will degrade performance by 12.32%

⚡ 1 improved benchmark
❌ 1 regressed benchmark
✅ 68 untouched benchmarks
⏩ 129 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
Encode_ASCII_32[TextEncoder][0/0/32] 3.4 ms 3 ms +13.19%
jsonResponse[Response] 37.6 µs 42.9 µs -12.32%

Comparing deathbyknowledge:props-type-parameter (404d283) with main (fd41c48)

Open in CodSpeed

Footnotes

  1. 129 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@kentonv
Copy link
Member

kentonv commented Feb 9, 2026

FWIW, while this change is fine, the last time someone proposed it, we figured out that they were using props in a way that wasn't intended.

ctx.props is not intended to be assigned by the application. It's intended to be filled in by the platform based on the binding used to invoke the entrypoint.

workers-auth-provider cheats a bit, but only because semantically I was trying to emulate what would happen if we had OAuth more built into the platform. It breaks the letter but keeps the spirit of the rule.

People should not, however, be using ctx.props as a place to stash their own data related to the request. They should use their own separate object for that. Or you could always assign some arbitrary property like ctx.mySpecialRequestData -- this is no worse than assigning into ctx.props.

@jasnell
Copy link
Collaborator

jasnell commented Feb 10, 2026

I'm not arguing for it one way or the other ... just asking ... should we consider making props effectively read-only by either (a) freezing it or (b) wrapping it such that assignments from user code are ignored?

@kentonv
Copy link
Member

kentonv commented Feb 11, 2026

@jasnell nah. Most JS APIs allow you to assign random properties on them even though it's probably not a great idea. No real reason to block it here, but also no reason to go out of our way to support it better.

@deathbyknowledge
Copy link
Author

ctx.mySpecialRequestData

Ack. We're currently using ctx.props in the Agents SDK but we'll explore declaring our own property on ctx directly.

Are we OK merging the changes here then?

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.

4 participants