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

Exception when using value object with a bigint in it (because svelte-select uses JSON.stringify on the value) #700

Open
samal-rasmussen opened this issue Aug 5, 2024 · 1 comment

Comments

@samal-rasmussen
Copy link

REPL:
https://svelte.dev/repl/f24b4451867d45bd855d1e333ad9518f?version=4.2.18

<script>
	import Select from 'svelte-select';

	let items = [
        { value: { id: 1n, name: 'One' }, label: 'One' },
        { value: { id: 2n, name: 'Two' }, label: 'Two' },
        { value: { id: 3n, name: 'three'}, label: 'Three' },
    ];
</script>

<Select {items} clearable={false} />

Error:

TypeError: Do not know how to serialize a BigInt
    at JSON.stringify (<anonymous>)
    at Object.update [as p] (eval at handle_message (about:srcdoc:21:8), <anonymous>:4836:12)
    at Object.update [as p] (eval at handle_message (about:srcdoc:21:8), <anonymous>:5285:37)
    at update (eval at handle_message (about:srcdoc:21:8), <anonymous>:631:31)
    at flush (eval at handle_message (about:srcdoc:21:8), <anonymous>:591:6)
@samal-rasmussen
Copy link
Author

samal-rasmussen commented Aug 5, 2024

JSON.stringify cannot be used with bigint. It's in the spec: GoogleChromeLabs/jsbi#30

There are a lot of values that don't serialize to JSON, so this will cause crashes if you take arbitrary values in from users of this lib and run them through JSON.stringify internally.

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

No branches or pull requests

1 participant