@@ -5,6 +5,7 @@ import http, { ServerResponse } from 'http'
5
5
import https from 'https'
6
6
import { isIPv6 } from 'net'
7
7
import path from 'path'
8
+ import process from 'process'
8
9
import { Duplex } from 'stream'
9
10
import util from 'util'
10
11
import zlib from 'zlib'
@@ -24,6 +25,7 @@ import { locatePath } from 'locate-path'
24
25
import { Match } from 'netlify-redirector'
25
26
import pFilter from 'p-filter'
26
27
import toReadableStream from 'to-readable-stream'
28
+ import throttle from 'lodash/throttle.js'
27
29
28
30
import { BaseCommand } from '../commands/index.js'
29
31
import { $TSFixMe , NetlifyOptions } from '../commands/types.js'
@@ -230,6 +232,13 @@ const alternativePathsFor = function (url) {
230
232
return paths
231
233
}
232
234
235
+ const notifyActivity = throttle ( ( api : NetlifyOptions [ 'api' ] , siteId : string , devServerId : string ) => {
236
+ // eslint-disable-next-line promise/prefer-await-to-callbacks, promise/prefer-await-to-then
237
+ api . markDevServerActivity ( { siteId, devServerId } ) . catch ( ( error ) => {
238
+ console . error ( `${ NETLIFYDEVWARN } Failed to notify activity` , error )
239
+ } )
240
+ } , 30 * 1000 )
241
+
233
242
const serveRedirect = async function ( {
234
243
env,
235
244
functionsRegistry,
@@ -718,6 +727,7 @@ const initializeProxy = async function ({
718
727
const onRequest = async (
719
728
{
720
729
addonsUrls,
730
+ api,
721
731
edgeFunctionsProxy,
722
732
env,
723
733
functionsRegistry,
@@ -790,6 +800,10 @@ const onRequest = async (
790
800
framework : settings . framework ,
791
801
}
792
802
803
+ if ( api && process . env . NETLIFY_DEV_SERVER_ID ) {
804
+ notifyActivity ( api , siteInfo . id , process . env . NETLIFY_DEV_SERVER_ID )
805
+ }
806
+
793
807
if ( match ) {
794
808
// We don't want to generate an ETag for 3xx redirects.
795
809
// @ts -expect-error TS(7031) FIXME: Binding element 'statusCode' implicitly has an 'an... Remove this comment to see the full error message
@@ -831,6 +845,7 @@ type EdgeFunctionsProxy = Awaited<ReturnType<typeof initializeEdgeFunctionsProxy
831
845
export const startProxy = async function ( {
832
846
accountId,
833
847
addonsUrls,
848
+ api,
834
849
blobsContext,
835
850
command,
836
851
config,
@@ -920,6 +935,7 @@ export const startProxy = async function ({
920
935
imageProxy,
921
936
siteInfo,
922
937
env,
938
+ api,
923
939
} )
924
940
const primaryServer = settings . https
925
941
? https . createServer ( { cert : settings . https . cert , key : settings . https . key } , onRequestWithOptions )
2 commit comments
github-actions[bot] commentedon Jun 13, 2024
📊 Benchmark results
github-actions[bot] commentedon Jun 13, 2024
📊 Benchmark results