Skip to content

Commit 2037ea9

Browse files
authored
docs: Request.userData must be serializable (#3327)
While passing complex objects might work between e.g. navigation hooks and the `requestHandler`, this cannot be generally relied upon, as all the storage backends serialize the request at some point.
1 parent a2fa3ee commit 2037ea9

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

packages/core/src/request.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,12 @@ export class Request<UserData extends Dictionary = Dictionary> {
125125
/** Private store for the custom user data assigned to the request. */
126126
private _userData: Record<string, any> = {};
127127

128-
/** Custom user data assigned to the request. */
128+
/**
129+
* Custom user data assigned to the request.
130+
*
131+
* All data stored in `userData` must be JSON-serializable.
132+
* Storing non-serializable values (e.g. functions, symbols) may result in unexpected results.
133+
*/
129134
userData: UserData = {} as UserData;
130135

131136
/**
@@ -486,6 +491,9 @@ export interface RequestOptions<UserData extends Dictionary = Dictionary> {
486491
/**
487492
* Custom user data assigned to the request. Use this to save any request related data to the
488493
* request's scope, keeping them accessible on retries, failures etc.
494+
*
495+
* All data stored in `userData` must be JSON-serializable.
496+
* Storing non-serializable values (e.g. functions, symbols) may result in unexpected results.
489497
*/
490498
userData?: UserData;
491499

0 commit comments

Comments
 (0)