vibe-gx 1.0.5 → 1.0.6
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/package.json +1 -1
- package/utils/core/handler.js +17 -4
- package/utils/core/parser.js +3 -0
package/package.json
CHANGED
package/utils/core/handler.js
CHANGED
|
@@ -140,21 +140,34 @@ export async function runIntercept(intercept, req, res, isRoute = true) {
|
|
|
140
140
|
*/
|
|
141
141
|
export function handleError(error, req, res) {
|
|
142
142
|
const isDev = process.env.NODE_ENV !== "production";
|
|
143
|
+
const message = error.message || "Unknown error";
|
|
143
144
|
|
|
144
145
|
// Log error (full stack in dev, message only in production)
|
|
145
146
|
if (isDev) {
|
|
146
147
|
console.error("[VIBE ERROR]:", error);
|
|
147
148
|
} else {
|
|
148
|
-
console.error("[VIBE ERROR]:",
|
|
149
|
+
console.error("[VIBE ERROR]:", message);
|
|
149
150
|
}
|
|
150
151
|
|
|
151
152
|
if (!res.headersSent) {
|
|
152
|
-
|
|
153
|
+
// Determine status code based on error type
|
|
154
|
+
let statusCode = 500;
|
|
155
|
+
let errorType = "Internal Server Error";
|
|
156
|
+
|
|
157
|
+
if (message.includes("exceeds max size")) {
|
|
158
|
+
statusCode = 413;
|
|
159
|
+
errorType = "Payload Too Large";
|
|
160
|
+
} else if (message.includes("not allowed")) {
|
|
161
|
+
statusCode = 415;
|
|
162
|
+
errorType = "Unsupported Media Type";
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
res.writeHead(statusCode, { "content-type": "application/json" });
|
|
153
166
|
|
|
154
167
|
// Only expose error details in development
|
|
155
168
|
const responseBody = isDev
|
|
156
|
-
? { error:
|
|
157
|
-
: { error:
|
|
169
|
+
? { error: errorType, message }
|
|
170
|
+
: { error: errorType };
|
|
158
171
|
|
|
159
172
|
res.end(JSON.stringify(responseBody));
|
|
160
173
|
}
|
package/utils/core/parser.js
CHANGED
|
@@ -161,6 +161,9 @@ function parseMultipart(req, res, media, options, resolve, reject) {
|
|
|
161
161
|
);
|
|
162
162
|
file.unpipe(writeStream);
|
|
163
163
|
writeStream.end();
|
|
164
|
+
// IMPORTANT: Resume the file stream to drain remaining data
|
|
165
|
+
// This allows busboy to finish parsing the multipart request
|
|
166
|
+
file.resume();
|
|
164
167
|
// Clean up partial file
|
|
165
168
|
fs.unlink(filePath, () => {
|
|
166
169
|
pendingWrites--;
|