Skip to content

Commit fcea5ad

Browse files
committed
fix: wrangler config not passed to cache population
1 parent b7771f1 commit fcea5ad

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

.changeset/icy-ends-roll.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@opennextjs/cloudflare": patch
3+
---
4+
5+
fix: wrangler config not passed to cache population

packages/cloudflare/src/cli/commands/populate-cache.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,11 @@ async function populateR2IncrementalCache(
148148
],
149149
// NOTE: R2 does not support the environment flag and results in the following error:
150150
// Incorrect type for the 'cacheExpiry' field on 'HttpMetadata': the provided value is not of type 'date'.
151-
{ target: populateCacheOptions.target, logging: "error" }
151+
{
152+
target: populateCacheOptions.target,
153+
configPath: populateCacheOptions.configPath,
154+
logging: "error",
155+
}
152156
);
153157
}
154158
logger.info(`Successfully populated cache with ${assets.length} assets`);
@@ -193,7 +197,9 @@ async function populateKVIncrementalCache(
193197
writeFileSync(chunkPath, JSON.stringify(kvMapping));
194198

195199
runWrangler(options, ["kv bulk put", quoteShellMeta(chunkPath), `--binding ${KV_CACHE_BINDING_NAME}`], {
196-
...populateCacheOptions,
200+
target: populateCacheOptions.target,
201+
environment: populateCacheOptions.environment,
202+
configPath: populateCacheOptions.configPath,
197203
logging: "error",
198204
});
199205

@@ -222,7 +228,12 @@ function populateD1TagCache(
222228
D1_TAG_BINDING_NAME,
223229
`--command "CREATE TABLE IF NOT EXISTS revalidations (tag TEXT NOT NULL, revalidatedAt INTEGER NOT NULL, UNIQUE(tag) ON CONFLICT REPLACE);"`,
224230
],
225-
{ ...populateCacheOptions, logging: "error" }
231+
{
232+
target: populateCacheOptions.target,
233+
environment: populateCacheOptions.environment,
234+
configPath: populateCacheOptions.configPath,
235+
logging: "error",
236+
}
226237
);
227238

228239
logger.info("\nSuccessfully created D1 table");

packages/cloudflare/src/cli/utils/run-wrangler.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export type WranglerTarget = "local" | "remote";
1111
type WranglerOptions = {
1212
target?: WranglerTarget;
1313
environment?: string;
14+
configPath?: string;
1415
logging?: "all" | "error";
1516
};
1617

@@ -65,6 +66,7 @@ export function runWrangler(options: BuildOptions, args: string[], wranglerOpts:
6566
[
6667
...args,
6768
wranglerOpts.environment && `--env ${wranglerOpts.environment}`,
69+
wranglerOpts.configPath && `--config ${wranglerOpts.configPath}`,
6870
wranglerOpts.target === "remote" && "--remote",
6971
wranglerOpts.target === "local" && "--local",
7072
].filter((v): v is string => !!v)

0 commit comments

Comments
 (0)