netlify 27.16.3 → 27.17.0
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/commands/deploy/deploy.js +0 -1
- package/dist/commands/logs/sources/server.js +11 -2
- package/dist/utils/deploy/deploy-site.d.ts +1 -2
- package/dist/utils/deploy/deploy-site.js +1 -2
- package/dist/utils/deploy/hash-fns.d.ts +1 -2
- package/dist/utils/deploy/hash-fns.js +6 -11
- package/dist/utils/proxy.js +54 -65
- package/package.json +1 -1
|
@@ -461,7 +461,6 @@ const runDeploy = async ({ alias, api, command, config, deployFolder, deployTime
|
|
|
461
461
|
workingDir: command.workingDir,
|
|
462
462
|
manifestPath: manifestPath ?? undefined,
|
|
463
463
|
packagePath,
|
|
464
|
-
serverEnabled: Boolean(siteData.feature_flags?.netlify_build_server_standalone),
|
|
465
464
|
serverManifestPath: serverManifestPath ?? undefined,
|
|
466
465
|
skipFunctionsCache,
|
|
467
466
|
siteRoot: site.root,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { debugFetch } from '../log-api.js';
|
|
2
|
-
// The API serves up to 500 lines a page
|
|
2
|
+
// The API serves up to 500 lines a page. MAX_PAGES bounds the pages read, so
|
|
3
|
+
// a long window doesn't page without end.
|
|
3
4
|
const PER_PAGE = 500;
|
|
4
5
|
const MAX_PAGES = 1 + 10_000 / PER_PAGE;
|
|
5
6
|
// Lines are stored a few seconds after their time, so each poll looks back
|
|
@@ -41,11 +42,18 @@ const fetchServerLogLines = async ({ apiBase, siteId, accessToken, from, to, lev
|
|
|
41
42
|
// orders by finer ones, so reversing is what keeps same-millisecond lines in order.
|
|
42
43
|
const lines = [];
|
|
43
44
|
const severity = severityFor(levels);
|
|
45
|
+
// An API that sends no cursor is paged by number.
|
|
46
|
+
let cursor;
|
|
44
47
|
for (let page = 1; page <= MAX_PAGES; page++) {
|
|
45
48
|
const url = new URL(`${apiBase}/sites/${encodeURIComponent(siteId)}/observability/server/logs`);
|
|
46
49
|
url.searchParams.set('from_ts', String(from));
|
|
47
50
|
url.searchParams.set('to_ts', String(to));
|
|
48
|
-
|
|
51
|
+
if (cursor) {
|
|
52
|
+
url.searchParams.set('cursor', cursor);
|
|
53
|
+
}
|
|
54
|
+
else if (page > 1) {
|
|
55
|
+
url.searchParams.set('page', String(page));
|
|
56
|
+
}
|
|
49
57
|
url.searchParams.set('per_page', String(PER_PAGE));
|
|
50
58
|
if (severity) {
|
|
51
59
|
url.searchParams.set('severity', severity);
|
|
@@ -63,6 +71,7 @@ const fetchServerLogLines = async ({ apiBase, siteId, accessToken, from, to, lev
|
|
|
63
71
|
if (!body.has_next_page) {
|
|
64
72
|
return { lines: lines.reverse(), truncated: false };
|
|
65
73
|
}
|
|
74
|
+
cursor = body.next_cursor;
|
|
66
75
|
}
|
|
67
76
|
return { lines: lines.reverse(), truncated: true };
|
|
68
77
|
};
|
|
@@ -23,7 +23,6 @@ export interface DeploySiteOptions {
|
|
|
23
23
|
manifestPath?: string | undefined;
|
|
24
24
|
maxRetry?: number;
|
|
25
25
|
packagePath?: string | undefined;
|
|
26
|
-
serverEnabled?: boolean;
|
|
27
26
|
serverManifestPath?: string | undefined;
|
|
28
27
|
siteRoot?: string | undefined;
|
|
29
28
|
skipFunctionsCache?: boolean | undefined;
|
|
@@ -32,7 +31,7 @@ export interface DeploySiteOptions {
|
|
|
32
31
|
tmpDir?: string;
|
|
33
32
|
workingDir: string;
|
|
34
33
|
}
|
|
35
|
-
export declare const deploySite: (command: BaseCommand, api: NetlifyAPI, siteId: string, dir: string, { branch, concurrentHash, concurrentUpload, config, deployId, deployTimeout, draft, environment, filter, fnDir, functionsConfig, hashAlgorithm, manifestPath, maxRetry, packagePath,
|
|
34
|
+
export declare const deploySite: (command: BaseCommand, api: NetlifyAPI, siteId: string, dir: string, { branch, concurrentHash, concurrentUpload, config, deployId, deployTimeout, draft, environment, filter, fnDir, functionsConfig, hashAlgorithm, manifestPath, maxRetry, packagePath, serverManifestPath, siteRoot, skipFunctionsCache, statusCb, syncFileLimit, tmpDir, workingDir, }: DeploySiteOptions) => Promise<{
|
|
36
35
|
deployId: string;
|
|
37
36
|
deploy: import("./util.js").ReadyDeploy;
|
|
38
37
|
uploadList: (import("./upload-files.js").EdgeFunctionUploadFile | import("./upload-files.js").ServerUploadFile | File | (import("./upload-files.js").FunctionUploadFile & {
|
|
@@ -18,7 +18,7 @@ const buildStatsString = (possibleParts) => {
|
|
|
18
18
|
}
|
|
19
19
|
return `${parts.slice(0, -1).join(', ')} and ${parts[parts.length - 1]}`;
|
|
20
20
|
};
|
|
21
|
-
export const deploySite = async (command, api, siteId, dir, { branch, concurrentHash = DEFAULT_CONCURRENT_HASH, concurrentUpload = DEFAULT_CONCURRENT_UPLOAD, config, deployId, deployTimeout = DEFAULT_DEPLOY_TIMEOUT, draft = false, environment, filter, fnDir = [], functionsConfig, hashAlgorithm, manifestPath, maxRetry = DEFAULT_MAX_RETRY, packagePath,
|
|
21
|
+
export const deploySite = async (command, api, siteId, dir, { branch, concurrentHash = DEFAULT_CONCURRENT_HASH, concurrentUpload = DEFAULT_CONCURRENT_UPLOAD, config, deployId, deployTimeout = DEFAULT_DEPLOY_TIMEOUT, draft = false, environment, filter, fnDir = [], functionsConfig, hashAlgorithm, manifestPath, maxRetry = DEFAULT_MAX_RETRY, packagePath, serverManifestPath, siteRoot, skipFunctionsCache, statusCb = () => {
|
|
22
22
|
/* default to noop */
|
|
23
23
|
}, syncFileLimit = DEFAULT_SYNC_LIMIT, tmpDir = temporaryDirectory(), workingDir, }) => {
|
|
24
24
|
statusCb({
|
|
@@ -47,7 +47,6 @@ export const deploySite = async (command, api, siteId, dir, { branch, concurrent
|
|
|
47
47
|
manifestPath,
|
|
48
48
|
packagePath,
|
|
49
49
|
serverConfig: config.server,
|
|
50
|
-
serverEnabled,
|
|
51
50
|
serverManifestPath,
|
|
52
51
|
skipFunctionsCache,
|
|
53
52
|
rootDir: siteRoot,
|
|
@@ -45,7 +45,7 @@ declare const toFunctionConfigPayload: (func: FunctionResult) => {
|
|
|
45
45
|
vcpu: number | undefined;
|
|
46
46
|
};
|
|
47
47
|
type FunctionConfigPayload = ReturnType<typeof toFunctionConfigPayload>;
|
|
48
|
-
declare const hashFns: (command: BaseCommand, directories: string[], { concurrentHash, functionsConfig, hashAlgorithm, manifestPath, packagePath, rootDir, serverConfig,
|
|
48
|
+
declare const hashFns: (command: BaseCommand, directories: string[], { concurrentHash, functionsConfig, hashAlgorithm, manifestPath, packagePath, rootDir, serverConfig, serverManifestPath, skipFunctionsCache, statusCb, tmpDir, }: {
|
|
49
49
|
concurrentHash?: number;
|
|
50
50
|
functionsConfig?: FunctionsConfig | undefined;
|
|
51
51
|
hashAlgorithm?: string | undefined;
|
|
@@ -53,7 +53,6 @@ declare const hashFns: (command: BaseCommand, directories: string[], { concurren
|
|
|
53
53
|
packagePath?: string | undefined;
|
|
54
54
|
rootDir?: string | undefined;
|
|
55
55
|
serverConfig?: NetlifyServerConfig | undefined;
|
|
56
|
-
serverEnabled?: boolean | undefined;
|
|
57
56
|
serverManifestPath?: string | undefined;
|
|
58
57
|
skipFunctionsCache?: boolean | undefined;
|
|
59
58
|
statusCb: StatusCallback;
|
|
@@ -52,10 +52,7 @@ const getFunctionZips = async ({ command, directories, functionsConfig, manifest
|
|
|
52
52
|
config: functionsConfig,
|
|
53
53
|
});
|
|
54
54
|
};
|
|
55
|
-
const getServerBundle = async ({ packagePath, rootDir, serverConfig,
|
|
56
|
-
if (!serverEnabled) {
|
|
57
|
-
return undefined;
|
|
58
|
-
}
|
|
55
|
+
const getServerBundle = async ({ packagePath, rootDir, serverConfig, serverManifestPath, tmpDir, }) => {
|
|
59
56
|
if (serverManifestPath) {
|
|
60
57
|
try {
|
|
61
58
|
const { server, timestamp } = JSON.parse(await readFile(serverManifestPath, 'utf-8'));
|
|
@@ -105,12 +102,7 @@ const toFunctionConfigPayload = (func) => ({
|
|
|
105
102
|
traffic_rules: trafficRulesConfig(func.trafficRules),
|
|
106
103
|
vcpu: func.vcpu,
|
|
107
104
|
});
|
|
108
|
-
const hashFns = async (command, directories, { concurrentHash, functionsConfig, hashAlgorithm = 'sha256', manifestPath, packagePath, rootDir, serverConfig,
|
|
109
|
-
// Exit early if there is nothing to bundle. A site can have a server without
|
|
110
|
-
// any functions directory.
|
|
111
|
-
if (directories.length === 0 && !serverEnabled) {
|
|
112
|
-
return { functions: {}, functionsWithNativeModules: [] };
|
|
113
|
-
}
|
|
105
|
+
const hashFns = async (command, directories, { concurrentHash, functionsConfig, hashAlgorithm = 'sha256', manifestPath, packagePath, rootDir, serverConfig, serverManifestPath, skipFunctionsCache, statusCb, tmpDir, }) => {
|
|
114
106
|
const [functionZips, serverBundle] = await Promise.all([
|
|
115
107
|
directories.length === 0
|
|
116
108
|
? []
|
|
@@ -124,8 +116,11 @@ const hashFns = async (command, directories, { concurrentHash, functionsConfig,
|
|
|
124
116
|
statusCb,
|
|
125
117
|
tmpDir,
|
|
126
118
|
}),
|
|
127
|
-
getServerBundle({ packagePath, rootDir, serverConfig,
|
|
119
|
+
getServerBundle({ packagePath, rootDir, serverConfig, serverManifestPath, tmpDir }),
|
|
128
120
|
]);
|
|
121
|
+
if (directories.length === 0 && serverBundle === undefined) {
|
|
122
|
+
return { functions: {}, functionsWithNativeModules: [] };
|
|
123
|
+
}
|
|
129
124
|
// ZISI's in-memory FunctionResult only nests bootstrap/runtime version into
|
|
130
125
|
// buildData when writing the manifest cache. Reconstruct it for direct-zip paths.
|
|
131
126
|
for (const func of functionZips) {
|
package/dist/utils/proxy.js
CHANGED
|
@@ -596,42 +596,40 @@ const onRequest = async ({ api, edgeFunctionsProxy, env, functionsRegistry, func
|
|
|
596
596
|
}
|
|
597
597
|
return proxy.web(req, res, { headers, target: functionsServer });
|
|
598
598
|
}
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
headers.append(req.rawHeaders[index], req.rawHeaders[index + 1]);
|
|
609
|
-
}
|
|
610
|
-
// The server handler gets a `Request` with no socket, so it reads the
|
|
611
|
-
// client's address from this header to set `context.ip`.
|
|
612
|
-
headers.set('x-forwarded-for', req.socket.remoteAddress ?? '');
|
|
613
|
-
const response = await serverMatch.handle(new Request(requestURL, {
|
|
614
|
-
body: req.originalBody,
|
|
615
|
-
headers,
|
|
616
|
-
method: req.method,
|
|
617
|
-
}));
|
|
618
|
-
await fromWebResponse(response, res);
|
|
619
|
-
return;
|
|
599
|
+
try {
|
|
600
|
+
const requestURL = reqToURL(req, req.url);
|
|
601
|
+
const serverMatch = await serverHandler.match(new Request(requestURL));
|
|
602
|
+
if (serverMatch) {
|
|
603
|
+
const staticFile = await getStatic(decodeURIComponent(requestURL.pathname), settings.dist ?? '');
|
|
604
|
+
if (!staticFile) {
|
|
605
|
+
const headers = new Headers();
|
|
606
|
+
for (let index = 0; index < req.rawHeaders.length; index += 2) {
|
|
607
|
+
headers.append(req.rawHeaders[index], req.rawHeaders[index + 1]);
|
|
620
608
|
}
|
|
609
|
+
// The server handler gets a `Request` with no socket, so it reads the
|
|
610
|
+
// client's address from this header to set `context.ip`.
|
|
611
|
+
headers.set('x-forwarded-for', req.socket.remoteAddress ?? '');
|
|
612
|
+
const response = await serverMatch.handle(new Request(requestURL, {
|
|
613
|
+
body: req.originalBody,
|
|
614
|
+
headers,
|
|
615
|
+
method: req.method,
|
|
616
|
+
}));
|
|
617
|
+
await fromWebResponse(response, res);
|
|
618
|
+
return;
|
|
621
619
|
}
|
|
622
620
|
}
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
else {
|
|
630
|
-
res.writeHead(500);
|
|
631
|
-
res.end(error instanceof Error ? error.message : 'Failed to serve request from Netlify Server');
|
|
632
|
-
}
|
|
633
|
-
return;
|
|
621
|
+
}
|
|
622
|
+
catch (error) {
|
|
623
|
+
// The response may have failed mid-stream, in which case the head is
|
|
624
|
+
// out and the only remaining option is dropping the connection.
|
|
625
|
+
if (res.headersSent) {
|
|
626
|
+
res.destroy();
|
|
634
627
|
}
|
|
628
|
+
else {
|
|
629
|
+
res.writeHead(500);
|
|
630
|
+
res.end(error instanceof Error ? error.message : 'Failed to serve request from Netlify Server');
|
|
631
|
+
}
|
|
632
|
+
return;
|
|
635
633
|
}
|
|
636
634
|
const match = await rewriter(req);
|
|
637
635
|
const options = {
|
|
@@ -721,26 +719,19 @@ export const startProxy = async function ({ accountId, aiGatewayContext, api, bl
|
|
|
721
719
|
logger: { log, warn, error: logError },
|
|
722
720
|
imagesConfig: config.images,
|
|
723
721
|
});
|
|
724
|
-
const
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
});
|
|
738
|
-
const handlerToStop = serverHandler;
|
|
739
|
-
runBeforeProcessExit(async () => {
|
|
740
|
-
await handlerToStop.stop();
|
|
741
|
-
await serverFileWatcher.close();
|
|
742
|
-
});
|
|
743
|
-
}
|
|
722
|
+
const serverFileWatcher = new FileWatcher();
|
|
723
|
+
const serverHandler = new ServerHandler({
|
|
724
|
+
accountID: siteInfo?.account_id,
|
|
725
|
+
fileWatcher: serverFileWatcher,
|
|
726
|
+
geolocation: mockLocation,
|
|
727
|
+
logger: { log, warn, error: logError },
|
|
728
|
+
projectRoot: projectDir,
|
|
729
|
+
siteID: siteInfo?.id,
|
|
730
|
+
});
|
|
731
|
+
runBeforeProcessExit(async () => {
|
|
732
|
+
await serverHandler.stop();
|
|
733
|
+
await serverFileWatcher.close();
|
|
734
|
+
});
|
|
744
735
|
const imageProxy = initializeImageProxy({
|
|
745
736
|
settings,
|
|
746
737
|
imageHandler,
|
|
@@ -794,19 +785,17 @@ export const startProxy = async function ({ accountId, aiGatewayContext, api, bl
|
|
|
794
785
|
? https.createServer({ cert: settings.https.cert, key: settings.https.key }, onRequestWithOptions)
|
|
795
786
|
: http.createServer(onRequestWithOptions);
|
|
796
787
|
const onUpgrade = async function onUpgrade(req, socket, head) {
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
return;
|
|
809
|
-
}
|
|
788
|
+
let handled = false;
|
|
789
|
+
try {
|
|
790
|
+
handled = await serverHandler.handleUpgrade(req, socket, head);
|
|
791
|
+
}
|
|
792
|
+
catch (error) {
|
|
793
|
+
logError(`Failed to hand over upgrade request to server: ${error instanceof Error ? error.message : String(error)}`);
|
|
794
|
+
socket.destroy();
|
|
795
|
+
return;
|
|
796
|
+
}
|
|
797
|
+
if (handled) {
|
|
798
|
+
return;
|
|
810
799
|
}
|
|
811
800
|
const match = await rewriter(req);
|
|
812
801
|
if (match && isExternal(match)) {
|