nitropack-nightly 2.11.0-20250303-165232.8dd35e61 → 2.11.0-20250303-180253.398eb4f3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/index.mjs +3 -6
- package/dist/meta/index.d.mts +1 -1
- package/dist/meta/index.d.ts +1 -1
- package/dist/meta/index.mjs +1 -1
- package/dist/presets/_unenv/preset-workerd.d.ts +3 -2
- package/dist/presets/_unenv/preset-workerd.mjs +16 -2
- package/dist/presets/cloudflare/preset.mjs +18 -28
- package/dist/presets/cloudflare/types.d.ts +14 -2
- package/dist/presets/cloudflare/utils.d.ts +2 -1
- package/dist/presets/cloudflare/utils.mjs +47 -18
- package/dist/presets/deno/runtime/deno-server.mjs +4 -4
- package/dist/presets/netlify/legacy/utils.mjs +2 -2
- package/dist/presets/node/runtime/node-cluster.mjs +1 -3
- package/dist/presets/vercel/utils.mjs +2 -2
- package/dist/rollup/index.mjs +3 -3
- package/dist/runtime/error.mjs +0 -1
- package/dist/runtime/internal/cache.mjs +4 -4
- package/dist/runtime/internal/error/dev.mjs +1 -4
- package/dist/runtime/internal/error/prod.mjs +1 -1
- package/dist/runtime/internal/task.mjs +1 -1
- package/dist/runtime/internal/utils.mjs +1 -1
- package/package.json +2 -2
package/dist/core/index.mjs
CHANGED
|
@@ -1925,8 +1925,8 @@ const JsonSigRx = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
|
|
|
1925
1925
|
const linkParents = /* @__PURE__ */ new Map();
|
|
1926
1926
|
async function prerender(nitro) {
|
|
1927
1927
|
if (nitro.options.noPublicDir) {
|
|
1928
|
-
|
|
1929
|
-
"
|
|
1928
|
+
nitro.logger.warn(
|
|
1929
|
+
"Skipping prerender since `noPublicDir` option is enabled."
|
|
1930
1930
|
);
|
|
1931
1931
|
return;
|
|
1932
1932
|
}
|
|
@@ -2332,15 +2332,12 @@ const defaultErrorHandler = defineNitroErrorHandler(
|
|
|
2332
2332
|
if (isSensitive) {
|
|
2333
2333
|
const tags = [error.unhandled && "[unhandled]", error.fatal && "[fatal]"].filter(Boolean).join(" ");
|
|
2334
2334
|
const columns = process.stderr.columns;
|
|
2335
|
-
if (!columns) {
|
|
2336
|
-
process.stdout.columns = 90;
|
|
2337
|
-
}
|
|
2338
2335
|
const ansiError = await (await youch.toANSI(error)).replaceAll(process.cwd(), ".");
|
|
2339
2336
|
if (!columns) {
|
|
2340
2337
|
process.stderr.columns = columns;
|
|
2341
2338
|
}
|
|
2342
2339
|
consola.error(
|
|
2343
|
-
`[
|
|
2340
|
+
`[request error] ${tags} [${event.method}] ${url}
|
|
2344
2341
|
|
|
2345
2342
|
`,
|
|
2346
2343
|
ansiError
|
package/dist/meta/index.d.mts
CHANGED
package/dist/meta/index.d.ts
CHANGED
package/dist/meta/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Preset } from "unenv";
|
|
2
2
|
import type { Plugin } from "rollup";
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
3
|
+
export declare const unenvCfExternals: Preset;
|
|
4
|
+
export declare const unenvWorkerdWithNodeCompat: Preset;
|
|
5
|
+
export declare const workerdHybridNodeCompatPlugin: Plugin;
|
|
@@ -3,7 +3,21 @@ import { join } from "pathe";
|
|
|
3
3
|
import { builtnNodeModules, hybridNodeModules } from "./node-compat/cloudflare.mjs";
|
|
4
4
|
const workerdDir = fileURLToPath(new URL("workerd/", import.meta.url));
|
|
5
5
|
const resolvePresetRuntime = (m) => join(workerdDir, `${m}.mjs`);
|
|
6
|
-
export const
|
|
6
|
+
export const unenvCfExternals = {
|
|
7
|
+
meta: {
|
|
8
|
+
name: "nitro-cloudflare:externals"
|
|
9
|
+
},
|
|
10
|
+
external: [
|
|
11
|
+
"cloudflare:email",
|
|
12
|
+
"cloudflare:sockets",
|
|
13
|
+
"cloudflare:workers",
|
|
14
|
+
"cloudflare:workflows"
|
|
15
|
+
]
|
|
16
|
+
};
|
|
17
|
+
export const unenvWorkerdWithNodeCompat = {
|
|
18
|
+
meta: {
|
|
19
|
+
name: "nitro-cloudflare:node-compat"
|
|
20
|
+
},
|
|
7
21
|
external: builtnNodeModules.map((m) => `node:${m}`),
|
|
8
22
|
alias: {
|
|
9
23
|
// (native)
|
|
@@ -25,7 +39,7 @@ export const unenvWorkerdPreset = {
|
|
|
25
39
|
)
|
|
26
40
|
}
|
|
27
41
|
};
|
|
28
|
-
export const
|
|
42
|
+
export const workerdHybridNodeCompatPlugin = {
|
|
29
43
|
name: "nitro:cloudflare:hybrid-node-compat",
|
|
30
44
|
resolveId(id) {
|
|
31
45
|
if (id.startsWith("cloudflare:")) {
|
|
@@ -1,31 +1,30 @@
|
|
|
1
1
|
import { defineNitroPreset } from "nitropack/kit";
|
|
2
2
|
import { writeFile } from "nitropack/kit";
|
|
3
3
|
import { resolve } from "pathe";
|
|
4
|
+
import { unenvCfExternals } from "../_unenv/preset-workerd.mjs";
|
|
4
5
|
import {
|
|
6
|
+
enableNodeCompat,
|
|
5
7
|
writeWranglerConfig,
|
|
6
8
|
writeCFRoutes,
|
|
7
9
|
writeCFPagesHeaders,
|
|
8
10
|
writeCFPagesRedirects
|
|
9
11
|
} from "./utils.mjs";
|
|
10
|
-
import { hybridNodePlugin, unenvWorkerdPreset } from "../_unenv/preset-workerd.mjs";
|
|
11
12
|
import cfLegacyPresets from "./preset-legacy.mjs";
|
|
12
|
-
const isWindows = process.platform === "win32";
|
|
13
|
-
const commandWithDir = (command) => isWindows ? `cmd /c "cd ./ && ${command}"` : `(cd ./ && ${command})`;
|
|
14
13
|
const cloudflarePages = defineNitroPreset(
|
|
15
14
|
{
|
|
16
15
|
extends: "cloudflare",
|
|
17
16
|
entry: "./runtime/cloudflare-pages",
|
|
18
17
|
exportConditions: ["workerd"],
|
|
19
18
|
commands: {
|
|
20
|
-
preview:
|
|
21
|
-
deploy:
|
|
19
|
+
preview: "npx wrangler --cwd ./ pages dev",
|
|
20
|
+
deploy: "npx wrangler --cwd ./ pages deploy"
|
|
22
21
|
},
|
|
23
22
|
output: {
|
|
24
23
|
dir: "{{ rootDir }}/dist",
|
|
25
24
|
publicDir: "{{ output.dir }}/{{ baseURL }}",
|
|
26
25
|
serverDir: "{{ output.dir }}/_worker.js"
|
|
27
26
|
},
|
|
28
|
-
unenv:
|
|
27
|
+
unenv: [unenvCfExternals],
|
|
29
28
|
alias: {
|
|
30
29
|
// Hotfix: Cloudflare appends /index.html if mime is not found and things like ico are not in standard lite.js!
|
|
31
30
|
// https://github.com/nitrojs/nitro/pull/933
|
|
@@ -36,7 +35,6 @@ const cloudflarePages = defineNitroPreset(
|
|
|
36
35
|
esmImport: true
|
|
37
36
|
},
|
|
38
37
|
rollupConfig: {
|
|
39
|
-
plugins: [hybridNodePlugin],
|
|
40
38
|
output: {
|
|
41
39
|
entryFileNames: "index.js",
|
|
42
40
|
format: "esm",
|
|
@@ -44,12 +42,11 @@ const cloudflarePages = defineNitroPreset(
|
|
|
44
42
|
}
|
|
45
43
|
},
|
|
46
44
|
hooks: {
|
|
45
|
+
"build:before": async (nitro) => {
|
|
46
|
+
await enableNodeCompat(nitro);
|
|
47
|
+
},
|
|
47
48
|
async compiled(nitro) {
|
|
48
|
-
await writeWranglerConfig(
|
|
49
|
-
nitro,
|
|
50
|
-
true
|
|
51
|
-
/* pages */
|
|
52
|
-
);
|
|
49
|
+
await writeWranglerConfig(nitro, "pages");
|
|
53
50
|
await writeCFRoutes(nitro);
|
|
54
51
|
await writeCFPagesHeaders(nitro);
|
|
55
52
|
await writeCFPagesRedirects(nitro);
|
|
@@ -70,16 +67,11 @@ const cloudflarePagesStatic = defineNitroPreset(
|
|
|
70
67
|
publicDir: "{{ output.dir }}/{{ baseURL }}"
|
|
71
68
|
},
|
|
72
69
|
commands: {
|
|
73
|
-
preview:
|
|
74
|
-
deploy:
|
|
70
|
+
preview: "npx wrangler --cwd ./ pages dev",
|
|
71
|
+
deploy: "npx wrangler --cwd ./ pages deploy"
|
|
75
72
|
},
|
|
76
73
|
hooks: {
|
|
77
74
|
async compiled(nitro) {
|
|
78
|
-
await writeWranglerConfig(
|
|
79
|
-
nitro,
|
|
80
|
-
true
|
|
81
|
-
/* pages */
|
|
82
|
-
);
|
|
83
75
|
await writeCFPagesHeaders(nitro);
|
|
84
76
|
await writeCFPagesRedirects(nitro);
|
|
85
77
|
}
|
|
@@ -98,12 +90,11 @@ const cloudflareModule = defineNitroPreset(
|
|
|
98
90
|
entry: "./runtime/cloudflare-module",
|
|
99
91
|
exportConditions: ["workerd"],
|
|
100
92
|
commands: {
|
|
101
|
-
preview:
|
|
102
|
-
deploy:
|
|
93
|
+
preview: "npx wrangler --cwd ./ dev",
|
|
94
|
+
deploy: "npx wrangler --cwd ./ deploy"
|
|
103
95
|
},
|
|
104
|
-
unenv:
|
|
96
|
+
unenv: [unenvCfExternals],
|
|
105
97
|
rollupConfig: {
|
|
106
|
-
plugins: [hybridNodePlugin],
|
|
107
98
|
output: {
|
|
108
99
|
format: "esm",
|
|
109
100
|
exports: "named",
|
|
@@ -115,12 +106,11 @@ const cloudflareModule = defineNitroPreset(
|
|
|
115
106
|
esmImport: true
|
|
116
107
|
},
|
|
117
108
|
hooks: {
|
|
109
|
+
"build:before": async (nitro) => {
|
|
110
|
+
await enableNodeCompat(nitro);
|
|
111
|
+
},
|
|
118
112
|
async compiled(nitro) {
|
|
119
|
-
await writeWranglerConfig(
|
|
120
|
-
nitro,
|
|
121
|
-
false
|
|
122
|
-
/* module */
|
|
123
|
-
);
|
|
113
|
+
await writeWranglerConfig(nitro, "module");
|
|
124
114
|
await writeFile(
|
|
125
115
|
resolve(nitro.options.output.dir, "package.json"),
|
|
126
116
|
JSON.stringify({ private: true, main: "./server/index.mjs" }, null, 2)
|
|
@@ -19,12 +19,24 @@ export interface CloudflareOptions {
|
|
|
19
19
|
*/
|
|
20
20
|
wrangler?: WranglerConfig;
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
22
|
+
* Enable native Node.js compatibility support.
|
|
23
|
+
*
|
|
24
|
+
* Requires `nodejs_compat` compatibility flag (Nitro enables it by default).
|
|
25
|
+
*
|
|
26
|
+
* If disabled, pure unenv polyfills will be used instead.
|
|
27
|
+
*
|
|
28
|
+
* Enabled by default with `compatibilityDate` >= `2025-03-01`.
|
|
29
|
+
*/
|
|
30
|
+
nodeCompat?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Disable the automatic generation of `.wrangler/deploy/config.json`.
|
|
33
|
+
*
|
|
34
|
+
* Enabled by default with `compatibilityDate` >= `2025-03-01` unless explicitly set to `false`.
|
|
23
35
|
*
|
|
24
36
|
* More info: https://developers.cloudflare.com/workers/wrangler/configuration#generated-wrangler-configuration
|
|
25
37
|
*/
|
|
26
38
|
noWranglerDeployConfig?: boolean;
|
|
27
|
-
pages
|
|
39
|
+
pages?: {
|
|
28
40
|
/**
|
|
29
41
|
* Nitro will automatically generate a `_routes.json` that controls which files get served statically and
|
|
30
42
|
* which get served by the Worker. Using this config will override the automatic `_routes.json`. Or, if the
|
|
@@ -2,4 +2,5 @@ import type { Nitro } from "nitropack/types";
|
|
|
2
2
|
export declare function writeCFRoutes(nitro: Nitro): Promise<void>;
|
|
3
3
|
export declare function writeCFPagesHeaders(nitro: Nitro): Promise<void>;
|
|
4
4
|
export declare function writeCFPagesRedirects(nitro: Nitro): Promise<void>;
|
|
5
|
-
export declare function
|
|
5
|
+
export declare function enableNodeCompat(nitro: Nitro): Promise<void>;
|
|
6
|
+
export declare function writeWranglerConfig(nitro: Nitro, cfTarget: "pages" | "module"): Promise<void>;
|
|
@@ -13,6 +13,10 @@ import {
|
|
|
13
13
|
withTrailingSlash,
|
|
14
14
|
withoutLeadingSlash
|
|
15
15
|
} from "ufo";
|
|
16
|
+
import {
|
|
17
|
+
workerdHybridNodeCompatPlugin,
|
|
18
|
+
unenvWorkerdWithNodeCompat
|
|
19
|
+
} from "../_unenv/preset-workerd.mjs";
|
|
16
20
|
export async function writeCFRoutes(nitro) {
|
|
17
21
|
const _cfPagesConfig = nitro.options.cloudflare?.pages || {};
|
|
18
22
|
const routes = {
|
|
@@ -133,13 +137,32 @@ export async function writeCFPagesRedirects(nitro) {
|
|
|
133
137
|
}
|
|
134
138
|
await writeFile(redirectsPath, contents.join("\n"), true);
|
|
135
139
|
}
|
|
136
|
-
|
|
140
|
+
const wranglerConfigAndUnenv2CompatDate = "2025-03-01";
|
|
141
|
+
export async function enableNodeCompat(nitro) {
|
|
142
|
+
const compatDate = nitro.options.compatibilityDate.cloudflare || nitro.options.compatibilityDate.default;
|
|
143
|
+
const nodeCompatEnabled = nitro.options.cloudflare?.nodeCompat ?? compatDate >= wranglerConfigAndUnenv2CompatDate;
|
|
144
|
+
if (compatDate < wranglerConfigAndUnenv2CompatDate && nitro.options.cloudflare?.nodeCompat === void 0) {
|
|
145
|
+
nitro.logger.warn(
|
|
146
|
+
`Current compatibility date "${compatDate}" does not supports native Node.js support in cloudflare workers. Please consider upgrading compatibilityDate to "${wranglerConfigAndUnenv2CompatDate}" or newer.`
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
if (nodeCompatEnabled) {
|
|
150
|
+
nitro.options.unenv.push(unenvWorkerdWithNodeCompat);
|
|
151
|
+
nitro.options.rollupConfig.plugins ??= [];
|
|
152
|
+
nitro.options.rollupConfig.plugins.push(
|
|
153
|
+
workerdHybridNodeCompatPlugin
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
nitro.options.cloudflare ??= {};
|
|
157
|
+
nitro.options.cloudflare.nodeCompat = nodeCompatEnabled;
|
|
158
|
+
}
|
|
159
|
+
export async function writeWranglerConfig(nitro, cfTarget) {
|
|
137
160
|
const wranglerConfigDir = nitro.options.output.serverDir;
|
|
138
161
|
const wranglerConfigPath = join(wranglerConfigDir, "wrangler.json");
|
|
139
162
|
const defaults = {};
|
|
140
163
|
const overrides = {};
|
|
141
|
-
defaults.compatibility_date = nitro.options.compatibilityDate.cloudflare || nitro.options.compatibilityDate.default;
|
|
142
|
-
if (
|
|
164
|
+
const compatDate = defaults.compatibility_date = nitro.options.compatibilityDate.cloudflare || nitro.options.compatibilityDate.default;
|
|
165
|
+
if (cfTarget === "pages") {
|
|
143
166
|
overrides.pages_build_output_dir = relative(
|
|
144
167
|
wranglerConfigDir,
|
|
145
168
|
nitro.options.output.publicDir
|
|
@@ -159,7 +182,7 @@ export async function writeWranglerConfig(nitro, isPages) {
|
|
|
159
182
|
for (const key in overrides) {
|
|
160
183
|
if (key in userConfig || key in ctxConfig) {
|
|
161
184
|
nitro.logger.warn(
|
|
162
|
-
`[
|
|
185
|
+
`[cloudflare] Wrangler config \`${key}\`${key in ctxConfig ? "set by config or modules" : ""} is overridden and will be ignored.`
|
|
163
186
|
);
|
|
164
187
|
}
|
|
165
188
|
}
|
|
@@ -170,19 +193,21 @@ export async function writeWranglerConfig(nitro, isPages) {
|
|
|
170
193
|
defaults
|
|
171
194
|
);
|
|
172
195
|
const compatFlags = new Set(wranglerConfig.compatibility_flags || []);
|
|
173
|
-
if (
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
196
|
+
if (nitro.options.cloudflare?.nodeCompat) {
|
|
197
|
+
if (compatFlags.has("nodejs_compat_v2") && compatFlags.has("no_nodejs_compat_v2")) {
|
|
198
|
+
nitro.logger.warn(
|
|
199
|
+
"[cloudflare] Wrangler config `compatibility_flags` contains both `nodejs_compat_v2` and `no_nodejs_compat_v2`. Ignoring `nodejs_compat_v2`."
|
|
200
|
+
);
|
|
201
|
+
compatFlags.delete("nodejs_compat_v2");
|
|
202
|
+
}
|
|
203
|
+
if (compatFlags.has("nodejs_compat_v2")) {
|
|
204
|
+
nitro.logger.warn(
|
|
205
|
+
"[cloudflare] Please consider replacing `nodejs_compat_v2` with `nodejs_compat` in your `compatibility_flags` or USE IT AT YOUR OWN RISK as it can cause issues with nitro."
|
|
206
|
+
);
|
|
207
|
+
} else {
|
|
208
|
+
compatFlags.add("nodejs_compat");
|
|
209
|
+
compatFlags.add("no_nodejs_compat_v2");
|
|
210
|
+
}
|
|
186
211
|
}
|
|
187
212
|
wranglerConfig.compatibility_flags = [...compatFlags];
|
|
188
213
|
await writeFile(
|
|
@@ -190,7 +215,11 @@ export async function writeWranglerConfig(nitro, isPages) {
|
|
|
190
215
|
JSON.stringify(wranglerConfig, null, 2),
|
|
191
216
|
true
|
|
192
217
|
);
|
|
193
|
-
|
|
218
|
+
let shouldWriteWranglerDeployConfig = compatDate >= wranglerConfigAndUnenv2CompatDate;
|
|
219
|
+
if (nitro.options.cloudflare?.noWranglerDeployConfig) {
|
|
220
|
+
shouldWriteWranglerDeployConfig = false;
|
|
221
|
+
}
|
|
222
|
+
if (shouldWriteWranglerDeployConfig) {
|
|
194
223
|
const configPath = join(
|
|
195
224
|
nitro.options.rootDir,
|
|
196
225
|
".wrangler/deploy/config.json"
|
|
@@ -9,20 +9,20 @@ const nitroApp = useNitroApp();
|
|
|
9
9
|
if (Deno.env.get("DEBUG")) {
|
|
10
10
|
addEventListener(
|
|
11
11
|
"unhandledrejection",
|
|
12
|
-
(event) => console.error("[
|
|
12
|
+
(event) => console.error("[unhandledRejection]", event.reason)
|
|
13
13
|
);
|
|
14
14
|
addEventListener(
|
|
15
15
|
"error",
|
|
16
|
-
(event) => console.error("[
|
|
16
|
+
(event) => console.error("[uncaughtException]", event.error)
|
|
17
17
|
);
|
|
18
18
|
} else {
|
|
19
19
|
addEventListener(
|
|
20
20
|
"unhandledrejection",
|
|
21
|
-
(err) => console.error("[
|
|
21
|
+
(err) => console.error("[unhandledRejection] " + err)
|
|
22
22
|
);
|
|
23
23
|
addEventListener(
|
|
24
24
|
"error",
|
|
25
|
-
(event) => console.error("[
|
|
25
|
+
(event) => console.error("[uncaughtException] " + event.error)
|
|
26
26
|
);
|
|
27
27
|
}
|
|
28
28
|
const serveOptions = {
|
|
@@ -123,8 +123,8 @@ export function deprecateSWR(nitro) {
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
if (hasLegacyOptions && !isTest) {
|
|
126
|
-
|
|
127
|
-
"
|
|
126
|
+
nitro.logger.warn(
|
|
127
|
+
"Nitro now uses `isr` option to configure ISR behavior on Netlify. Backwards-compatible support for `static` and `swr` support with Builder Functions will be removed in the future versions. Set `future.nativeSWR: true` nitro config disable this warning."
|
|
128
128
|
);
|
|
129
129
|
}
|
|
130
130
|
}
|
|
@@ -24,9 +24,7 @@ function runMaster() {
|
|
|
24
24
|
isShuttingDown = true;
|
|
25
25
|
await new Promise((resolve) => {
|
|
26
26
|
const timeout = setTimeout(() => {
|
|
27
|
-
console.warn(
|
|
28
|
-
"[nitro] [cluster] Timeout reached for graceful shutdown. Forcing exit."
|
|
29
|
-
);
|
|
27
|
+
console.warn("Timeout reached for graceful shutdown. Forcing exit.");
|
|
30
28
|
resolve();
|
|
31
29
|
}, shutdownConfig.timeout);
|
|
32
30
|
cluster.on("exit", () => {
|
|
@@ -192,8 +192,8 @@ export function deprecateSWR(nitro) {
|
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
if (hasLegacyOptions && !isTest) {
|
|
195
|
-
|
|
196
|
-
"
|
|
195
|
+
nitro.logger.warn(
|
|
196
|
+
"Nitro now uses `isr` option to configure ISR behavior on Vercel. Backwards-compatible support for `static` and `swr` options within the Vercel Build Options API will be removed in the future versions. Set `future.nativeSWR: true` nitro config disable this warning."
|
|
197
197
|
);
|
|
198
198
|
}
|
|
199
199
|
}
|
package/dist/rollup/index.mjs
CHANGED
|
@@ -1153,8 +1153,8 @@ function handlersMeta(nitro) {
|
|
|
1153
1153
|
}
|
|
1154
1154
|
}
|
|
1155
1155
|
} catch (error) {
|
|
1156
|
-
|
|
1157
|
-
`[
|
|
1156
|
+
nitro.logger.warn(
|
|
1157
|
+
`[handlers-meta] Cannot extra route meta for: ${id}: ${error}`
|
|
1158
1158
|
);
|
|
1159
1159
|
}
|
|
1160
1160
|
return {
|
|
@@ -1924,7 +1924,7 @@ const getRollupConfig = (nitro) => {
|
|
|
1924
1924
|
rollupConfig.plugins.push(appConfig(nitro));
|
|
1925
1925
|
rollupConfig.plugins.push(handlers(nitro));
|
|
1926
1926
|
if (nitro.options.experimental.openAPI) {
|
|
1927
|
-
rollupConfig.plugins.push(handlersMeta());
|
|
1927
|
+
rollupConfig.plugins.push(handlersMeta(nitro));
|
|
1928
1928
|
}
|
|
1929
1929
|
rollupConfig.plugins.push(errorHandler(nitro));
|
|
1930
1930
|
rollupConfig.plugins.push(
|
package/dist/runtime/error.mjs
CHANGED
|
@@ -28,13 +28,13 @@ export function defineCachedFunction(fn, opts = {}) {
|
|
|
28
28
|
async function get(key, resolver, shouldInvalidateCache, event) {
|
|
29
29
|
const cacheKey = [opts.base, group, name, key + ".json"].filter(Boolean).join(":").replace(/:\/$/, ":index");
|
|
30
30
|
let entry = await useStorage().getItem(cacheKey).catch((error) => {
|
|
31
|
-
console.error(`[
|
|
31
|
+
console.error(`[cache] Cache read error.`, error);
|
|
32
32
|
useNitroApp().captureError(error, { event, tags: ["cache"] });
|
|
33
33
|
}) || {};
|
|
34
34
|
if (typeof entry !== "object") {
|
|
35
35
|
entry = {};
|
|
36
36
|
const error = new Error("Malformed data read from cache.");
|
|
37
|
-
console.error("[
|
|
37
|
+
console.error("[cache]", error);
|
|
38
38
|
useNitroApp().captureError(error, { event, tags: ["cache"] });
|
|
39
39
|
}
|
|
40
40
|
const ttl = (opts.maxAge ?? 0) * 1e3;
|
|
@@ -71,7 +71,7 @@ export function defineCachedFunction(fn, opts = {}) {
|
|
|
71
71
|
setOpts = { ttl: opts.maxAge };
|
|
72
72
|
}
|
|
73
73
|
const promise = useStorage().setItem(cacheKey, entry, setOpts).catch((error) => {
|
|
74
|
-
console.error(`[
|
|
74
|
+
console.error(`[cache] Cache write error.`, error);
|
|
75
75
|
useNitroApp().captureError(error, { event, tags: ["cache"] });
|
|
76
76
|
});
|
|
77
77
|
if (event?.waitUntil) {
|
|
@@ -88,7 +88,7 @@ export function defineCachedFunction(fn, opts = {}) {
|
|
|
88
88
|
}
|
|
89
89
|
if (opts.swr && validate(entry) !== false) {
|
|
90
90
|
_resolvePromise.catch((error) => {
|
|
91
|
-
console.error(`[
|
|
91
|
+
console.error(`[cache] SWR handler error.`, error);
|
|
92
92
|
useNitroApp().captureError(error, { event, tags: ["cache"] });
|
|
93
93
|
});
|
|
94
94
|
return entry;
|
|
@@ -25,15 +25,12 @@ export default defineNitroErrorHandler(
|
|
|
25
25
|
if (isSensitive) {
|
|
26
26
|
const tags = [error.unhandled && "[unhandled]", error.fatal && "[fatal]"].filter(Boolean).join(" ");
|
|
27
27
|
const columns = process.stderr.columns;
|
|
28
|
-
if (!columns) {
|
|
29
|
-
process.stdout.columns = 90;
|
|
30
|
-
}
|
|
31
28
|
const ansiError = await (await youch.toANSI(error)).replaceAll(process.cwd(), ".");
|
|
32
29
|
if (!columns) {
|
|
33
30
|
process.stderr.columns = columns;
|
|
34
31
|
}
|
|
35
32
|
consola.error(
|
|
36
|
-
`[
|
|
33
|
+
`[request error] ${tags} [${event.method}] ${url}
|
|
37
34
|
|
|
38
35
|
`,
|
|
39
36
|
ansiError
|
|
@@ -15,7 +15,7 @@ export default defineNitroErrorHandler(
|
|
|
15
15
|
if (isSensitive) {
|
|
16
16
|
const tags = [error.unhandled && "[unhandled]", error.fatal && "[fatal]"].filter(Boolean).join(" ");
|
|
17
17
|
console.error(
|
|
18
|
-
`[
|
|
18
|
+
`[request error] ${tags} [${event.method}] ${url}
|
|
19
19
|
`,
|
|
20
20
|
error
|
|
21
21
|
);
|
|
@@ -26,7 +26,7 @@ export async function useRequestBody(request) {
|
|
|
26
26
|
return URL.createObjectURL(blob);
|
|
27
27
|
}
|
|
28
28
|
function _captureError(error, type) {
|
|
29
|
-
console.error(`[
|
|
29
|
+
console.error(`[${type}]`, error);
|
|
30
30
|
useNitroApp().captureError(error, { tags: [type] });
|
|
31
31
|
}
|
|
32
32
|
export function trapUnhandledNodeErrors() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nitropack-nightly",
|
|
3
|
-
"version": "2.11.0-20250303-
|
|
3
|
+
"version": "2.11.0-20250303-180253.398eb4f3",
|
|
4
4
|
"description": "Build and Deploy Universal JavaScript Servers",
|
|
5
5
|
"repository": "nitrojs/nitro",
|
|
6
6
|
"license": "MIT",
|
|
@@ -170,7 +170,7 @@
|
|
|
170
170
|
"unstorage": "^1.15.0",
|
|
171
171
|
"untyped": "^2.0.0",
|
|
172
172
|
"unwasm": "^0.3.9",
|
|
173
|
-
"youch": "4.1.0-beta.
|
|
173
|
+
"youch": "4.1.0-beta.5",
|
|
174
174
|
"youch-core": "^0.3.1"
|
|
175
175
|
},
|
|
176
176
|
"devDependencies": {
|