Add Bun image transformation docs#7961
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🍈 Lychee Link Check Report21 links: ✅ All links are working!Full Statistics Table
|
|
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (1)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughAdds a new Prisma Compute docs page ( ChangesCompute Docs: Image Transformations
Blog Post: Image Transformations with Bun on Prisma Compute
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/docs/content/docs/compute/image-transformations.mdx`:
- Line 23: The spell checker (cspell) is flagging the legitimate technical terms
`lanczos3` and `EXIF` as spelling errors in the documentation. Instead of
modifying the documentation prose, add these terms to the cspell dictionary
whitelist configuration file (typically cspell.json or similar configuration at
the project root). This will allow the spell checker to recognize these
technical terms as valid and pass CI without altering the documentation content.
Ensure both `lanczos3` and `EXIF` are added to the words list since they appear
across multiple lines in the document (lines 23, 80, and 355).
- Around line 141-147: The Cache-Control header in the Response constructor
includes the "immutable" directive, but since the source asset is fetched by
name only (products/chair.jpg) without version or hash, the upstream asset can
change in place and users will remain stuck on stale versions. Remove the
"immutable" directive from the Cache-Control header and either add
versioning/hash to the source URL path or replace it with a shorter max-age TTL
combined with ETag-based cache revalidation strategy to handle source updates
properly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 5bad8cc6-70b8-46bf-bee4-40359aa157cb
⛔ Files ignored due to path filters (1)
apps/blog/public/image-transformations-with-bun-on-prisma-compute/imgs/hero.svgis excluded by!**/*.svg
📒 Files selected for processing (4)
apps/blog/content/blog/image-transformations-with-bun-on-prisma-compute/index.mdxapps/docs/content/docs/compute/image-transformations.mdxapps/docs/content/docs/compute/index.mdxapps/docs/content/docs/compute/meta.json
| | Resize by width or width and height | `resize(width)` or `resize(width, height)` | | ||
| | Preserve aspect ratio inside a box | `resize(width, height, { fit: "inside" })` | | ||
| | Prevent upscaling | `resize(width, height, { withoutEnlargement: true })` | | ||
| | Choose resize filter | `filter: "lanczos3"`, `"mitchell"`, `"box"`, `"nearest"`, and others | |
There was a problem hiding this comment.
Whitelist the technical spellcheck terms.
lanczos3 and EXIF are legitimate technical terms, but cspell is already failing on them in CI. Please add them to the docs dictionary instead of changing the prose.
Also applies to: 80-80, 355-355
🧰 Tools
🪛 GitHub Actions: Spellcheck / 0_Validate documentation spelling.txt
[error] 23-23: cspell (lint:spellcheck) reported an unknown word: 'lanczos' (context: resize filter; suggesting 'lanczos3'/'mitchell').
🪛 GitHub Actions: Spellcheck / Validate documentation spelling
[error] 23-23: cspell: Unknown word (lanczos) at 23:36. Context: filter: "lanczos3", "mitchell", ...
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@apps/docs/content/docs/compute/image-transformations.mdx` at line 23, The
spell checker (cspell) is flagging the legitimate technical terms `lanczos3` and
`EXIF` as spelling errors in the documentation. Instead of modifying the
documentation prose, add these terms to the cspell dictionary whitelist
configuration file (typically cspell.json or similar configuration at the
project root). This will allow the spell checker to recognize these technical
terms as valid and pass CI without altering the documentation content. Ensure
both `lanczos3` and `EXIF` are added to the words list since they appear across
multiple lines in the document (lines 23, 80, and 355).
Source: Pipeline failures
| return new Response(body, { | ||
| headers: { | ||
| "Cache-Control": "public, max-age=31536000, immutable", | ||
| "Content-Type": body.type, | ||
| "Vary": "Accept", | ||
| }, | ||
| }); |
There was a problem hiding this comment.
Don't mark mutable source URLs as immutable.
This example fetches products/chair.jpg by name only, so Cache-Control: immutable can leave users stuck on stale variants if the upstream asset changes in place. Either version the source path/hash or switch this sample to a shorter TTL/ETag strategy.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@apps/docs/content/docs/compute/image-transformations.mdx` around lines 141 -
147, The Cache-Control header in the Response constructor includes the
"immutable" directive, but since the source asset is fetched by name only
(products/chair.jpg) without version or hash, the upstream asset can change in
place and users will remain stuck on stale versions. Remove the "immutable"
directive from the Cache-Control header and either add versioning/hash to the
source URL path or replace it with a shorter max-age TTL combined with
ETag-based cache revalidation strategy to handle source updates properly.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
apps/blog/content/blog/image-transformations-with-bun-on-prisma-compute/index.mdx (1)
254-273: ⚡ Quick winIntegration snippet may cause copy-paste confusion due to incomplete variable scope.
The code snippet at lines 254–273 shows how to wire the filesystem cache into your route, but it references
width,height,quality,fit, andformatvariables that aren't defined in this partial view. A developer copying this snippet directly will get undefined reference errors. The variables are defined in the outer full route example (lines 98–139), but the connection isn't explicit.Consider either:
- Adding a comment in the snippet explicitly stating "These variables come from the parameter parsing section above" and referencing line numbers, or
- Showing the full route context so it's clear these are from the parameter-parsing section.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/blog/content/blog/image-transformations-with-bun-on-prisma-compute/index.mdx` around lines 254 - 273, The code snippet in the route handler references undefined variables (width, height, quality, fit, and format) that are not defined within this partial view. These variables are defined in the parameter-parsing section earlier in the full route example. Add a clear comment at the beginning of this code snippet stating that these variables come from the parameter-parsing section above, or restructure the documentation to show the complete route context by including the parameter-parsing code before this cache-integration snippet so the variable definitions and their usage are together in one continuous example.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@apps/blog/content/blog/image-transformations-with-bun-on-prisma-compute/index.mdx`:
- Around line 237-239: The pathFor function uses Bun.hash(key) without a seed
argument, which generates random process-specific hashes that differ across
process restarts, breaking cache consistency. Fix this by adding a fixed seed
value as the second argument to Bun.hash() in the pathFor function, changing
Bun.hash(key) to Bun.hash(key, 0) to ensure the same input always produces the
same hash output regardless of when or where the process runs.
---
Nitpick comments:
In
`@apps/blog/content/blog/image-transformations-with-bun-on-prisma-compute/index.mdx`:
- Around line 254-273: The code snippet in the route handler references
undefined variables (width, height, quality, fit, and format) that are not
defined within this partial view. These variables are defined in the
parameter-parsing section earlier in the full route example. Add a clear comment
at the beginning of this code snippet stating that these variables come from the
parameter-parsing section above, or restructure the documentation to show the
complete route context by including the parameter-parsing code before this
cache-integration snippet so the variable definitions and their usage are
together in one continuous example.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 963cc44f-8249-4e4f-bf24-72153266aa45
📒 Files selected for processing (1)
apps/blog/content/blog/image-transformations-with-bun-on-prisma-compute/index.mdx
| function pathFor(key: string) { | ||
| return `${CACHE_DIR}/${Bun.hash(key).toString(16)}`; | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
Does Bun.hash() produce deterministic output across process restarts and what seed does it use?
💡 Result:
Bun.hash does not produce deterministic output across process restarts by default because it uses a random seed when none is provided [1][2]. To ensure deterministic output that remains consistent across process restarts or different environments, you must explicitly provide a seed as the second argument to the function [1][2]. Regarding the seed: - Default behavior: When the seed argument is omitted, Bun uses a random, process-specific seed [1]. This means that calling Bun.hash('data') will return different results each time the process is restarted [1]. - Deterministic usage: You can achieve consistent output by passing a fixed numeric value (number or bigint) as the seed [1][3]. For example, Bun.hash('data', 0) will consistently produce the same output every time [1]. It is also important to note that Bun.hash is a non-cryptographic hash function based on algorithms like Wyhash [4][3]. While providing a seed makes the hash deterministic for a specific input across restarts, users have reported that the underlying hash implementation can sometimes yield different results for the same input across different operating systems or platforms (e.g., Windows vs. Linux) [5]. If cross-platform or environment-independent stability is required, it is recommended to test your specific use case or consider alternative hashing solutions [5].
Citations:
- 1: https://zhcndoc-bun.mintlify.app/api/hashing
- 2: https://bun.com/docs/runtime/hashing
- 3: https://fossies.org/linux/bun/docs/runtime/hashing.mdx
- 4: https://bun.sh/reference/bun/hash
- 5: Bug: /buddy generates different companion on Windows vs WSL for same account anthropics/claude-code#44115
Fix the non-deterministic hash function that breaks the cache across process restarts.
The cache key generation uses Bun.hash(key).toString(16) without a seed argument. By default, Bun.hash() uses a random, process-specific seed, meaning the same input produces different hashes after each restart. This makes the filesystem cache ineffective across warm instances or redeploys—each new process generates new cache keys and misses all prior cached data.
To fix this, provide a fixed seed as the second argument: Bun.hash(key, 0).toString(16). This ensures consistent cache keys across all instances and deployments. If you need cryptographic guarantees, consider SHA256 instead, though for cache keys the determinism is the critical requirement here.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@apps/blog/content/blog/image-transformations-with-bun-on-prisma-compute/index.mdx`
around lines 237 - 239, The pathFor function uses Bun.hash(key) without a seed
argument, which generates random process-specific hashes that differ across
process restarts, breaking cache consistency. Fix this by adding a fixed seed
value as the second argument to Bun.hash() in the pathFor function, changing
Bun.hash(key) to Bun.hash(key, 0) to ensure the same input always produces the
same hash output regardless of when or where the process runs.
Summary by CodeRabbit
/images/*example, caching headers and negotiation guidance, source-handling best practices, and a security checklist.