-
Notifications
You must be signed in to change notification settings - Fork 86
fix: handle case of zero-length cacheable route handler responses #2819
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
fix: handle case of zero-length cacheable route handler responses #2819
Conversation
📊 Package size report 0.02%↑
Unchanged files
🤖 This report was automatically generated by pkg-size-action |
…ory cache failures not fatal
} | ||
let knownKindFailed = false | ||
if (valueToStore.value?.kind === 'ROUTE' || valueToStore.value?.kind === 'APP_ROUTE') { | ||
return BASE_BLOB_SIZE + valueToStore.value.body.length |
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.
This in particular is the fix for added test case.
But using it as example, I did add more adjustments:
- ensure we add "base" blob size to all known cases
- ensure
estimateBlobSize
returns "PositiveNumber
" - make using in-memory store non-fatal - this is optimization, but failures related to it should NOT cause crashes. I did add recording of failures there so we can adjust code if problems happen still
} | ||
|
||
const estimateBlobSize = (valueToStore: BlobType | null | Promise<unknown>): PositiveNumber => { | ||
let knownTypeFailed = false |
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.
Technically, you could omit this var now that you're using estimateBlobKnownTypeSizeError
. It's only used in the warning message below, which could be replaced by checking if estimateBlobKnownTypeSizeError
is not undefined
, but it's not a blocker, just something to consider next time you're touching the code here.
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.
I'll adjust now - it's unlikely this will be done as follow up
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.
f1ab628 dropped that extra unneded variable. Also added calculated size to warning just for it to have a bit more information
Description
Size calculcation for in-memory store in some cases was returning 0 (in particular known case is cacheable route handler with 0-length body).
This PR does few things:
Tests
Added known case that is causing errors with currently released version
Relevant links (GitHub issues, etc.) or a picture of cute animal
https://linear.app/netlify/issue/FRB-1721/sizecalculation-return-invalid-expect-positive-integer