Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape hatch added to defaultSerializeQueryArgs for unserializable data #4297

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

riqts
Copy link
Contributor

@riqts riqts commented Mar 23, 2024

fixes #4279

There's some discussion there about the expected behaviour and potential other fixes involving additional options or control for a user to override the defaultSerializeQueryArgs implementation.

I figured this is the best initial starting point because if defaultQueryArgs does throw an error due to say BigInt being passed, it will just continue the process that involves running the user defined serializeQueryArgs anyway.

I am not sure what the handling for the error should be. I presume a warning being sent every single time this happens especially if a user is aware it will happen isn't what we want? But I wanted to put something there for clarity.

Copy link

codesandbox bot commented Mar 23, 2024

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 2639cea:

Sandbox Source
rsk-github-issues-example Configuration
@examples-query-react/basic Configuration
@examples-query-react/advanced Configuration
@examples-action-listener/counter Configuration
rtk-esm-cra Configuration

Copy link

netlify bot commented Mar 23, 2024

Deploy Preview for redux-starter-kit-docs ready!

Name Link
🔨 Latest commit 2639cea
🔍 Latest deploy log https://app.netlify.com/sites/redux-starter-kit-docs/deploys/65fed32d7322650008f5208a
😎 Deploy Preview https://deploy-preview-4297--redux-starter-kit-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -27,6 +29,12 @@ export const defaultSerializeQueryArgs: SerializeQueryArgs<any> = ({
}, {})
: value,
)
} catch (e) {
Copy link
Contributor

@rkofman rkofman Mar 26, 2024

Choose a reason for hiding this comment

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

(I'm relatively new to open source process && this project, so if I should keep my comments to the issue rather than the PR, please let me know -- or if I'm missing too much context to be useful)

I suspect that for most use cases, silently swallowing an error is worse than throwing it. We probably don't want a silent divergence in behavior based on the input type.

Copy link
Contributor Author

@riqts riqts Mar 26, 2024

Choose a reason for hiding this comment

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

This doesn't actually change the majority of the behaviour by just catching this. As seralizeQueryArgs still runs so if the user has provided a way to handle it changing, or if the query args is actually changing it will still behave as normal.

I have a test added to indicate that the base render assumptions don't change with this addition. Is that what you are referring to? or the actual handling. Because I definitely want guidance on the best approach to handling the error rather than my dev mode warning.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, I have a thought! Let me put together a PR.

Copy link
Contributor

@rkofman rkofman Mar 30, 2024

Choose a reason for hiding this comment

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

See: #4315

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.

useStableQueryArgs chokes on BigInt
2 participants