Skip to content

fix cache population for R2 #644

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

Merged
merged 2 commits into from
May 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/violet-lemons-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@opennextjs/cloudflare": patch
---

fix cache population for R2
2 changes: 1 addition & 1 deletion packages/cloudflare/src/cli/commands/populate-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ async function populateR2IncrementalCache(
["r2 object put", quoteShellMeta(path.join(bucket, cacheKey)), `--file ${quoteShellMeta(fullPath)}`],
// NOTE: R2 does not support the environment flag and results in the following error:
// Incorrect type for the 'cacheExpiry' field on 'HttpMetadata': the provided value is not of type 'date'.
{ target: populateCacheOptions.target, excludeRemoteFlag: true, logging: "error" }
{ target: populateCacheOptions.target, logging: "error" }
);
}
logger.info(`Successfully populated cache with ${assets.length} assets`);
Expand Down
3 changes: 1 addition & 2 deletions packages/cloudflare/src/cli/utils/run-wrangler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export type WranglerTarget = "local" | "remote";
type WranglerOptions = {
target?: WranglerTarget;
environment?: string;
excludeRemoteFlag?: boolean;
logging?: "all" | "error";
};

Expand Down Expand Up @@ -66,7 +65,7 @@ export function runWrangler(options: BuildOptions, args: string[], wranglerOpts:
[
...args,
wranglerOpts.environment && `--env ${wranglerOpts.environment}`,
wranglerOpts.target === "remote" && !wranglerOpts.excludeRemoteFlag && "--remote",
wranglerOpts.target === "remote" && "--remote",
wranglerOpts.target === "local" && "--local",
].filter((v): v is string => !!v)
),
Expand Down