You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
req.context values shared between different payload.find*() calls if req gets passed #10250
Let me first start with the reproduction case before getting into more details:
First start a payload.find() over a collection with several matching documents.
Context is empty here.
Payload fetches all documents and executes all collection hooks for those documents.
In a collection hook we call payload.findById({ context: { value: 5 }, req }). A context value is set and req is passed (using shared transactions for instance).
So far so good for the first document of the payload.find() operation but in the hooks for the second and later documents context.value is now 5 right away.
Payload should not use the same context object through all hook operations. Context values passed to sub operations should not influence the context values are previous or still ongoing operations like the payload.find() one.
On first glance, this makes sense to me. You want the context to follow through explicitly where you passed it, but right now, it's shared across all operations.
We will need to think through this one to make sure that we can change this without any negative repercussions.
Activity
jmikrut commentedon Dec 30, 2024
On first glance, this makes sense to me. You want the context to follow through explicitly where you passed it, but right now, it's shared across all operations.
We will need to think through this one to make sure that we can change this without any negative repercussions.
@r1tsuu let's think through this a bit!
cbratschi commentedon Dec 30, 2024
Could you please also have a look at: #9960
This issue caused me a lot of headache and still need to patch every Payload version. Related to hook handling too and easy to fix.
JessRynkar commentedon Feb 20, 2026
Hi @cbratschi! Are you still experiencing this on the latest version
v3.77.0?cbratschi commentedon Feb 20, 2026
@JessRynkar Yes, the Payload architecture is still the same.
fix: resolve six request, validation and developer tooling reports
fix: address 24 Payload read, schema, version and tooling reports (#9)