-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
feat: warn if page endpoint body is not serializable #5635
Conversation
🦋 Changeset detectedLatest commit: 6780d98 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
import { coalesce_to_error } from '../../../utils/error.js'; | ||
import { domain_matches, path_matches } from './cookie.js'; | ||
import { is_pojo, warn_if_not_serdeable } from './utils.js'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL that serdeable is an actual word 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Serde is common in the rust circles. Guess it hasn't carried over much outside, will change if it's not clear although need suggestions cause I'm horrible at it.
/** | ||
* @param {any} v | ||
*/ | ||
export function is_pojo(v) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It irks me a little that there's another function with the same name which does something different, and both have no short description so you have to jump into the code and usage locations to know what's this about.
Also: What's the TODO
about?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the other one does a lot of other stuff specific to Response body types that's not actually checking if it's a plain object. I did want to rename it but likely in a separate PR that touches that part of the code.
The TODO
is lodash's implementations making me paranoid about some weird JavaScript behaviors that I'm unaware of.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a comment about this with a link to lodash's implementation and something like "if people ever run into weird edge cases where this doesn't behave as expected, look into lodash's implementation more closely"?
|
||
/** @param {any} v */ | ||
export function is_serializable_primitive(v) { | ||
// TODO: javascript-isms |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the TODO
about?
Gmail told me to look at the CI, and jesus christ that's scary, going to look at it tomorrow |
Ughh, |
It occurred to me that since we always need to serialize the data, we can do the checks at serialization time with a custom |
#4944 #5358 #5545
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. All changesets should bepatch
until SvelteKit 1.0