@netlify/build 29.28.1 → 29.28.2
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/lib/error/parse/serialize_status.d.ts +10 -13
- package/lib/error/parse/serialize_status.js +1 -1
- package/lib/error/types.d.ts +2 -1
- package/lib/error/types.js +12 -0
- package/lib/plugins/spawn.js +3 -1
- package/lib/steps/error.d.ts +24 -16
- package/lib/steps/error.js +32 -16
- package/lib/steps/plugin.d.ts +1 -1
- package/lib/steps/plugin.js +3 -3
- package/lib/steps/return.d.ts +7 -7
- package/package.json +2 -2
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}): {
|
|
11
|
-
state: any;
|
|
12
|
-
title: any;
|
|
13
|
-
summary: any;
|
|
1
|
+
import type { BuildError } from '../types.js';
|
|
2
|
+
type ErrorState = 'failed_build' | 'failed_plugin' | 'canceled_build';
|
|
3
|
+
export declare const serializeErrorStatus: ({ fullErrorInfo: { title, message, locationInfo, errorProps, errorMetadata }, state, }: {
|
|
4
|
+
fullErrorInfo: BuildError;
|
|
5
|
+
state: ErrorState;
|
|
6
|
+
}) => {
|
|
7
|
+
state: ErrorState;
|
|
8
|
+
title: string | (import("../types.js").TitleFunction & string);
|
|
9
|
+
summary: string;
|
|
14
10
|
text: string | undefined;
|
|
15
11
|
extraData: any;
|
|
16
12
|
};
|
|
13
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/* Serialize an error object to `statuses` properties */
|
|
2
2
|
export const serializeErrorStatus = function ({ fullErrorInfo: { title, message, locationInfo, errorProps, errorMetadata }, state, }) {
|
|
3
3
|
const text = getText({ locationInfo, errorProps });
|
|
4
4
|
return { state, title, summary: message, text, extraData: errorMetadata };
|
package/lib/error/types.d.ts
CHANGED
|
@@ -165,10 +165,11 @@ declare const ErrorTypeMap: {
|
|
|
165
165
|
readonly pluginInternal: "pluginInternal";
|
|
166
166
|
readonly ipc: "ipc";
|
|
167
167
|
readonly corePlugin: "corePlugin";
|
|
168
|
+
readonly trustedPlugin: "trustedPlugin";
|
|
168
169
|
readonly coreStep: "coreStep";
|
|
169
170
|
readonly api: "api";
|
|
170
171
|
readonly exception: "exception";
|
|
171
172
|
readonly telemetry: "telemetry";
|
|
172
173
|
};
|
|
173
|
-
type ErrorTypes = keyof typeof ErrorTypeMap;
|
|
174
|
+
export type ErrorTypes = keyof typeof ErrorTypeMap;
|
|
174
175
|
export {};
|
package/lib/error/types.js
CHANGED
|
@@ -141,6 +141,7 @@ const ErrorTypeMap = {
|
|
|
141
141
|
pluginInternal: 'pluginInternal',
|
|
142
142
|
ipc: 'ipc',
|
|
143
143
|
corePlugin: 'corePlugin',
|
|
144
|
+
trustedPlugin: 'trustedPlugin',
|
|
144
145
|
coreStep: 'coreStep',
|
|
145
146
|
api: 'api',
|
|
146
147
|
exception: 'exception',
|
|
@@ -293,6 +294,17 @@ const TYPES = {
|
|
|
293
294
|
locationType: 'buildFail',
|
|
294
295
|
severity: 'error',
|
|
295
296
|
},
|
|
297
|
+
/**
|
|
298
|
+
* Trusted plugin internal error (all of our `@netlify/*` plugins).
|
|
299
|
+
*/
|
|
300
|
+
trustedPlugin: {
|
|
301
|
+
title: ({ location: { packageName } }) => `Plugin "${packageName}" internal error`,
|
|
302
|
+
stackType: 'stack',
|
|
303
|
+
showErrorProps: true,
|
|
304
|
+
rawStack: true,
|
|
305
|
+
locationType: 'buildFail',
|
|
306
|
+
severity: 'error',
|
|
307
|
+
},
|
|
296
308
|
/**
|
|
297
309
|
* Core step internal error
|
|
298
310
|
*/
|
package/lib/plugins/spawn.js
CHANGED
|
@@ -36,7 +36,9 @@ const startPlugin = async function ({ pluginDir, nodePath, buildDir, childEnv, s
|
|
|
36
36
|
execPath: nodePath,
|
|
37
37
|
env: childEnv,
|
|
38
38
|
extendEnv: false,
|
|
39
|
-
stdio: isTrustedPlugin(pluginPackageJson) && systemLogFile
|
|
39
|
+
stdio: isTrustedPlugin(pluginPackageJson?.name) && systemLogFile
|
|
40
|
+
? ['pipe', 'pipe', 'pipe', 'ipc', systemLogFile]
|
|
41
|
+
: undefined,
|
|
40
42
|
});
|
|
41
43
|
try {
|
|
42
44
|
await getEventFromChild(childProcess, 'ready');
|
package/lib/steps/error.d.ts
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import { ErrorTypes } from '../error/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Handle build command errors and plugin errors:
|
|
4
|
+
* - usually, propagate the error to make the build stop.
|
|
5
|
+
* - `utils.build.cancelBuild()` also cancels the build by calling the API
|
|
6
|
+
* - `utils.build.failPlugin()` or post-deploy errors do not make the build
|
|
7
|
+
* stop, but are still reported, and prevent future events from the same
|
|
8
|
+
* plugin.
|
|
9
|
+
* This also computes error statuses that are sent to the API.
|
|
10
|
+
*/
|
|
11
|
+
export declare const handleStepError: ({ event, newError, childEnv, mode, api, errorMonitor, deployId, coreStep, netlifyConfig, logs, debug, testOpts, }: {
|
|
2
12
|
event: any;
|
|
3
13
|
newError: any;
|
|
4
14
|
childEnv: any;
|
|
@@ -11,38 +21,36 @@ export function handleStepError({ event, newError, childEnv, mode, api, errorMon
|
|
|
11
21
|
logs: any;
|
|
12
22
|
debug: any;
|
|
13
23
|
testOpts: any;
|
|
14
|
-
})
|
|
15
|
-
failedPlugin:
|
|
24
|
+
}) => Promise<{
|
|
25
|
+
failedPlugin: string[];
|
|
16
26
|
newStatus: {
|
|
17
|
-
state:
|
|
18
|
-
title:
|
|
19
|
-
summary:
|
|
27
|
+
state: "failed_build" | "failed_plugin" | "canceled_build";
|
|
28
|
+
title: string | (import("../error/types.js").TitleFunction & string);
|
|
29
|
+
summary: string;
|
|
20
30
|
text: string | undefined;
|
|
21
31
|
extraData: any;
|
|
22
32
|
};
|
|
23
33
|
}> | Promise<{
|
|
24
34
|
newError: any;
|
|
25
35
|
newStatus: {
|
|
26
|
-
state:
|
|
27
|
-
title:
|
|
28
|
-
summary:
|
|
36
|
+
state: "failed_build" | "failed_plugin" | "canceled_build";
|
|
37
|
+
title: string | (import("../error/types.js").TitleFunction & string);
|
|
38
|
+
summary: string;
|
|
29
39
|
text: string | undefined;
|
|
30
40
|
extraData: any;
|
|
31
41
|
};
|
|
32
42
|
}> | {
|
|
33
43
|
newError: any;
|
|
34
44
|
newStatus: {
|
|
35
|
-
state:
|
|
36
|
-
title:
|
|
37
|
-
summary:
|
|
45
|
+
state: "failed_build" | "failed_plugin" | "canceled_build";
|
|
46
|
+
title: string | (import("../error/types.js").TitleFunction & string);
|
|
47
|
+
summary: string;
|
|
38
48
|
text: string | undefined;
|
|
39
49
|
extraData: any;
|
|
40
50
|
};
|
|
41
51
|
} | {
|
|
42
52
|
newError: any;
|
|
43
53
|
};
|
|
44
|
-
export
|
|
45
|
-
type?:
|
|
46
|
-
} | {
|
|
47
|
-
type: string;
|
|
54
|
+
export declare const getPluginErrorType: (error: Error, loadedFrom: string, packageName?: string) => {
|
|
55
|
+
type?: ErrorTypes;
|
|
48
56
|
};
|
package/lib/steps/error.js
CHANGED
|
@@ -2,15 +2,19 @@ import { cancelBuild } from '../error/cancel.js';
|
|
|
2
2
|
import { handleBuildError } from '../error/handle.js';
|
|
3
3
|
import { getFullErrorInfo, parseErrorInfo } from '../error/parse/parse.js';
|
|
4
4
|
import { serializeErrorStatus } from '../error/parse/serialize_status.js';
|
|
5
|
+
import { isPluginLocation } from '../error/types.js';
|
|
5
6
|
import { isSoftFailEvent } from '../plugins/events.js';
|
|
6
7
|
import { addErrorToActiveSpan, addEventToActiveSpan } from '../tracing/main.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
import { isTrustedPlugin } from './plugin.js';
|
|
9
|
+
/**
|
|
10
|
+
* Handle build command errors and plugin errors:
|
|
11
|
+
* - usually, propagate the error to make the build stop.
|
|
12
|
+
* - `utils.build.cancelBuild()` also cancels the build by calling the API
|
|
13
|
+
* - `utils.build.failPlugin()` or post-deploy errors do not make the build
|
|
14
|
+
* stop, but are still reported, and prevent future events from the same
|
|
15
|
+
* plugin.
|
|
16
|
+
* This also computes error statuses that are sent to the API.
|
|
17
|
+
*/
|
|
14
18
|
export const handleStepError = function ({ event, newError, childEnv, mode, api, errorMonitor, deployId, coreStep, netlifyConfig, logs, debug, testOpts, }) {
|
|
15
19
|
addErrorToActiveSpan(newError);
|
|
16
20
|
// Core steps do not report error statuses
|
|
@@ -18,7 +22,7 @@ export const handleStepError = function ({ event, newError, childEnv, mode, api,
|
|
|
18
22
|
return { newError };
|
|
19
23
|
}
|
|
20
24
|
const fullErrorInfo = getFullErrorInfo({ error: newError, colors: false, debug });
|
|
21
|
-
const { errorInfo
|
|
25
|
+
const { errorInfo, message, title, type } = fullErrorInfo;
|
|
22
26
|
if (type === 'failPlugin' || isSoftFailEvent(event)) {
|
|
23
27
|
return handleFailPlugin({
|
|
24
28
|
fullErrorInfo,
|
|
@@ -36,32 +40,40 @@ export const handleStepError = function ({ event, newError, childEnv, mode, api,
|
|
|
36
40
|
const cancellationAttributes = {
|
|
37
41
|
'build.cancellation.title': title,
|
|
38
42
|
'build.cancellation.message': message,
|
|
39
|
-
'build.cancellation.packageName': packageName,
|
|
40
43
|
};
|
|
44
|
+
if (isPluginLocation(errorInfo.location)) {
|
|
45
|
+
cancellationAttributes['build.cancellation.packageName'] = errorInfo.location.packageName;
|
|
46
|
+
}
|
|
41
47
|
addEventToActiveSpan('build.cancelled', cancellationAttributes);
|
|
42
48
|
return handleCancelBuild({ fullErrorInfo, newError, api, deployId });
|
|
43
49
|
}
|
|
44
50
|
return handleFailBuild({ fullErrorInfo, newError });
|
|
45
51
|
};
|
|
46
|
-
|
|
47
|
-
const handleFailPlugin = async function ({ fullErrorInfo,
|
|
52
|
+
/* On `utils.build.failPlugin()` or during `onSuccess` or `onEnd` */
|
|
53
|
+
const handleFailPlugin = async function ({ fullErrorInfo, newError, childEnv, mode, errorMonitor, netlifyConfig, logs, debug, testOpts, }) {
|
|
48
54
|
const newStatus = serializeErrorStatus({ fullErrorInfo, state: 'failed_plugin' });
|
|
49
55
|
await handleBuildError(newError, { errorMonitor, netlifyConfig, childEnv, mode, logs, debug, testOpts });
|
|
50
|
-
|
|
56
|
+
// TODO we should probably use type guard here, but due to the way we build these errorInfo objects I'm not 100%
|
|
57
|
+
// confident we have all the properties currently required by the type
|
|
58
|
+
const location = fullErrorInfo.errorInfo.location;
|
|
59
|
+
return { failedPlugin: [location.packageName], newStatus };
|
|
51
60
|
};
|
|
52
|
-
|
|
61
|
+
/* On `utils.build.cancelBuild()` */
|
|
53
62
|
const handleCancelBuild = async function ({ fullErrorInfo, newError, api, deployId }) {
|
|
54
63
|
const newStatus = serializeErrorStatus({ fullErrorInfo, state: 'canceled_build' });
|
|
55
64
|
await cancelBuild({ api, deployId });
|
|
56
65
|
return { newError, newStatus };
|
|
57
66
|
};
|
|
58
|
-
|
|
67
|
+
/* On `utils.build.failBuild()` or uncaught exception */
|
|
59
68
|
const handleFailBuild = function ({ fullErrorInfo, newError }) {
|
|
60
69
|
const newStatus = serializeErrorStatus({ fullErrorInfo, state: 'failed_build' });
|
|
61
70
|
return { newError, newStatus };
|
|
62
71
|
};
|
|
63
|
-
|
|
64
|
-
export const getPluginErrorType = function (error, loadedFrom) {
|
|
72
|
+
/* Unlike community plugins, core plugin and trusted plugin bugs should be handled as system errors */
|
|
73
|
+
export const getPluginErrorType = function (error, loadedFrom, packageName) {
|
|
74
|
+
if (isTrustedPluginBug(error, packageName)) {
|
|
75
|
+
return { type: 'trustedPlugin' };
|
|
76
|
+
}
|
|
65
77
|
if (!isCorePluginBug(error, loadedFrom)) {
|
|
66
78
|
return {};
|
|
67
79
|
}
|
|
@@ -71,3 +83,7 @@ const isCorePluginBug = function (error, loadedFrom) {
|
|
|
71
83
|
const { severity } = parseErrorInfo(error);
|
|
72
84
|
return severity === 'warning' && loadedFrom === 'core';
|
|
73
85
|
};
|
|
86
|
+
const isTrustedPluginBug = function (error, packageName) {
|
|
87
|
+
const { severity } = parseErrorInfo(error);
|
|
88
|
+
return severity === 'warning' && isTrustedPlugin(packageName);
|
|
89
|
+
};
|
package/lib/steps/plugin.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function isTrustedPlugin(
|
|
1
|
+
export function isTrustedPlugin(packageName: any): any;
|
|
2
2
|
export function firePluginStep({ event, childProcess, packageName, packagePath, pluginPackageJson, loadedFrom, origin, envChanges, errorParams, configOpts, netlifyConfig, configMutations, headersPath, redirectsPath, constants, steps, error, logs, featureFlags, debug, verbose, }: {
|
|
3
3
|
event: any;
|
|
4
4
|
childProcess: any;
|
package/lib/steps/plugin.js
CHANGED
|
@@ -5,7 +5,7 @@ import { callChild } from '../plugins/ipc.js';
|
|
|
5
5
|
import { getSuccessStatus } from '../status/success.js';
|
|
6
6
|
import { getPluginErrorType } from './error.js';
|
|
7
7
|
import { updateNetlifyConfig, listConfigSideFiles } from './update_config.js';
|
|
8
|
-
export const isTrustedPlugin = (
|
|
8
|
+
export const isTrustedPlugin = (packageName) => packageName?.startsWith('@netlify/');
|
|
9
9
|
// Fire a plugin step
|
|
10
10
|
export const firePluginStep = async function ({ event, childProcess, packageName, packagePath, pluginPackageJson, loadedFrom, origin, envChanges, errorParams, configOpts, netlifyConfig, configMutations, headersPath, redirectsPath, constants, steps, error, logs, featureFlags, debug, verbose, }) {
|
|
11
11
|
const listeners = pipePluginOutput(childProcess, logs);
|
|
@@ -18,7 +18,7 @@ export const firePluginStep = async function ({ event, childProcess, packageName
|
|
|
18
18
|
event,
|
|
19
19
|
error,
|
|
20
20
|
envChanges,
|
|
21
|
-
featureFlags: isTrustedPlugin(pluginPackageJson) ? featureFlags : undefined,
|
|
21
|
+
featureFlags: isTrustedPlugin(pluginPackageJson?.name) ? featureFlags : undefined,
|
|
22
22
|
netlifyConfig,
|
|
23
23
|
constants,
|
|
24
24
|
},
|
|
@@ -49,7 +49,7 @@ export const firePluginStep = async function ({ event, childProcess, packageName
|
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
catch (newError) {
|
|
52
|
-
const errorType = getPluginErrorType(newError, loadedFrom);
|
|
52
|
+
const errorType = getPluginErrorType(newError, loadedFrom, packageName);
|
|
53
53
|
addErrorInfo(newError, {
|
|
54
54
|
...errorType,
|
|
55
55
|
plugin: { pluginPackageJson, packageName },
|
package/lib/steps/return.d.ts
CHANGED
|
@@ -24,20 +24,20 @@ export function getStepReturn({ event, packageName, newError, newEnvChanges, new
|
|
|
24
24
|
quiet: any;
|
|
25
25
|
metrics: any;
|
|
26
26
|
}): Promise<{
|
|
27
|
-
failedPlugin:
|
|
27
|
+
failedPlugin: string[];
|
|
28
28
|
newStatus: {
|
|
29
|
-
state:
|
|
30
|
-
title:
|
|
31
|
-
summary:
|
|
29
|
+
state: "failed_build" | "failed_plugin" | "canceled_build";
|
|
30
|
+
title: string | (import("../error/types.js").TitleFunction & string);
|
|
31
|
+
summary: string;
|
|
32
32
|
text: string | undefined;
|
|
33
33
|
extraData: any;
|
|
34
34
|
};
|
|
35
35
|
}> | Promise<{
|
|
36
36
|
newError: any;
|
|
37
37
|
newStatus: {
|
|
38
|
-
state:
|
|
39
|
-
title:
|
|
40
|
-
summary:
|
|
38
|
+
state: "failed_build" | "failed_plugin" | "canceled_build";
|
|
39
|
+
title: string | (import("../error/types.js").TitleFunction & string);
|
|
40
|
+
summary: string;
|
|
41
41
|
text: string | undefined;
|
|
42
42
|
extraData: any;
|
|
43
43
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/build",
|
|
3
|
-
"version": "29.28.
|
|
3
|
+
"version": "29.28.2",
|
|
4
4
|
"description": "Netlify build module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./lib/index.js",
|
|
@@ -154,5 +154,5 @@
|
|
|
154
154
|
"engines": {
|
|
155
155
|
"node": "^14.16.0 || >=16.0.0"
|
|
156
156
|
},
|
|
157
|
-
"gitHead": "
|
|
157
|
+
"gitHead": "db2b375439203dc1c7ec1e68b24b8460c8f0ffc3"
|
|
158
158
|
}
|