@qzsy/vinext 0.1.85 → 0.1.86

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.
@@ -20,10 +20,10 @@ import { parseNextHttpErrorDigest } from "./next-error-digest.js";
20
20
  import { matchPrerenderRouteParamsPayload, readTrustedPrerenderRouteParams, serializePrerenderRouteParamsHeader } from "./prerender-route-params.js";
21
21
  import { getRenderedConcreteUrlPathsForRoute } from "./pregenerated-concrete-paths.js";
22
22
  import { pickRootParams, setRootParams } from "../shims/root-params.js";
23
- import { flattenErrorCauses } from "../utils/error-cause.js";
24
23
  import { createServerActionNotFoundResponse, getServerActionNotFoundMessage } from "./server-action-not-found.js";
25
24
  import { buildPageCacheTags } from "./implicit-tags.js";
26
25
  import { buildPostMwRequestContext } from "./app-post-middleware-context.js";
26
+ import { flattenErrorCauses } from "../utils/error-cause.js";
27
27
  import { finalizeAppRscResponse } from "./app-rsc-response-finalizer.js";
28
28
  import { normalizeRscRequest } from "./app-rsc-request-normalization.js";
29
29
  import { runWithPrerenderWorkUnit } from "./prerender-work-unit-setup.js";
@@ -613,11 +613,15 @@ async function handleServerActionRscRequest(options) {
613
613
  }
614
614
  }
615
615
  } finally {
616
- if (shouldLogAction) actionLogInfo = createServerActionLogInfo({
617
- actionId: options.actionId,
618
- args,
619
- durationMs: Math.round(performance.now() - actionLogStart)
620
- });
616
+ if (shouldLogAction) try {
617
+ actionLogInfo = createServerActionLogInfo({
618
+ actionId: options.actionId,
619
+ args,
620
+ durationMs: Math.round(performance.now() - actionLogStart)
621
+ });
622
+ } catch {
623
+ actionLogInfo = null;
624
+ }
621
625
  options.setHeadersAccessPhase(previousHeadersPhase);
622
626
  if (actionThrew && !actionWasForwarded) rootParamsUsage.transitionToRender();
623
627
  }
@@ -28,6 +28,16 @@ const DEFAULT_ARG_SANITIZE_LIMITS = {
28
28
  maxObjectKeys: 3,
29
29
  maxDepth: 2
30
30
  };
31
+ function isPlainObject(value) {
32
+ const proto = Object.getPrototypeOf(value);
33
+ return proto === Object.prototype || proto === null;
34
+ }
35
+ function describeOpaqueArg(arg) {
36
+ if (Array.isArray(arg)) return `[Array(${arg.length})]`;
37
+ if (typeof FormData !== "undefined" && arg instanceof FormData) return "[FormData]";
38
+ if (typeof Blob !== "undefined" && arg instanceof Blob) return `[${arg.constructor.name}]`;
39
+ return `[${arg.constructor.name}]`;
40
+ }
31
41
  function sanitizeArgForLog(arg, depth = 0, limits = DEFAULT_ARG_SANITIZE_LIMITS) {
32
42
  if (arg === null || arg === void 0) return arg;
33
43
  if (typeof arg === "string") return truncateString(arg, limits.maxStringLength);
@@ -40,14 +50,17 @@ function sanitizeArgForLog(arg, depth = 0, limits = DEFAULT_ARG_SANITIZE_LIMITS)
40
50
  if (arg.length > limits.maxArrayItems) items.push("...");
41
51
  return items;
42
52
  }
43
- if (typeof arg === "object") try {
44
- const entries = Object.entries(arg).slice(0, limits.maxObjectKeys);
45
- const sanitized = {};
46
- for (const [key, value] of entries) sanitized[key] = sanitizeArgForLog(value, depth + 1, limits);
47
- if (Object.keys(arg).length > limits.maxObjectKeys) sanitized["..."] = "...";
48
- return sanitized;
49
- } catch {
50
- return "[Object]";
53
+ if (typeof arg === "object") {
54
+ if (!isPlainObject(arg)) return describeOpaqueArg(arg);
55
+ try {
56
+ const entries = Object.entries(arg).slice(0, limits.maxObjectKeys);
57
+ const sanitized = {};
58
+ for (const [key, value] of entries) sanitized[key] = sanitizeArgForLog(value, depth + 1, limits);
59
+ if (Object.keys(arg).length > limits.maxObjectKeys) sanitized["..."] = "...";
60
+ return sanitized;
61
+ } catch {
62
+ return "[Object]";
63
+ }
51
64
  }
52
65
  try {
53
66
  return truncateString(JSON.stringify(arg), limits.maxStringLength);
@@ -55,6 +68,22 @@ function sanitizeArgForLog(arg, depth = 0, limits = DEFAULT_ARG_SANITIZE_LIMITS)
55
68
  return "[unserializable]";
56
69
  }
57
70
  }
71
+ /** Snapshot args without spreading lazy Flight arrays or throwing on bad payloads. */
72
+ function safeArgsSnapshotForLog(args) {
73
+ let length;
74
+ try {
75
+ length = args.length;
76
+ } catch {
77
+ return ["(args unavailable)"];
78
+ }
79
+ const snapshot = [];
80
+ for (let index = 0; index < length; index++) try {
81
+ snapshot.push(sanitizeArgForLog(args[index]));
82
+ } catch {
83
+ snapshot.push("(arg unavailable)");
84
+ }
85
+ return snapshot;
86
+ }
58
87
  function sanitizeArgsForLog(args, limits = DEFAULT_ARG_SANITIZE_LIMITS) {
59
88
  return args.map((arg) => sanitizeArgForLog(arg, 0, limits));
60
89
  }
@@ -203,12 +232,20 @@ function createServerActionLogInfo(options) {
203
232
  if (!isDevServerActionLoggingEnabled()) return null;
204
233
  const meta = resolveServerActionLogMeta(options.actionId);
205
234
  if (!meta) return null;
206
- const args = Array.isArray(options.args) ? options.args : [options.args];
207
- return {
208
- ...meta,
209
- args: sanitizeArgsForLog([...args]),
210
- duration: options.durationMs
211
- };
235
+ try {
236
+ const args = Array.isArray(options.args) ? options.args : [options.args];
237
+ return {
238
+ ...meta,
239
+ args: safeArgsSnapshotForLog(args),
240
+ duration: options.durationMs
241
+ };
242
+ } catch {
243
+ return {
244
+ ...meta,
245
+ args: ["(args unavailable)"],
246
+ duration: options.durationMs
247
+ };
248
+ }
212
249
  }
213
250
  //#endregion
214
251
  export { applyServerActionLogHeader, createServerActionLogInfo, formatActionArgs, isDevServerActionLoggingEnabled, parseServerActionLogHeader, resolveServerActionLogMeta, serializeServerActionLogHeader };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qzsy/vinext",
3
- "version": "0.1.85",
3
+ "version": "0.1.86",
4
4
  "description": "Run Next.js apps on Vite. Drop-in replacement for the next CLI.",
5
5
  "license": "MIT",
6
6
  "repository": {