diff --git a/src/events/http/HttpServer.js b/src/events/http/HttpServer.js index 6564c82cf..3e214ae14 100644 --- a/src/events/http/HttpServer.js +++ b/src/events/http/HttpServer.js @@ -23,10 +23,10 @@ import debugLog from '../../debugLog.js' import serverlessLog, { logRoutes } from '../../serverlessLog.js' import { detectEncoding, + generateHapiPath, getHttpApiCorsConfig, jsonPath, splitHandlerPathAndName, - generateHapiPath, } from '../../utils/index.js' const { parse, stringify } = JSON diff --git a/src/events/http/authJWTSettingsExtractor.js b/src/events/http/authJWTSettingsExtractor.js index 5a712de59..1de8bedaa 100644 --- a/src/events/http/authJWTSettingsExtractor.js +++ b/src/events/http/authJWTSettingsExtractor.js @@ -13,7 +13,9 @@ export default function authJWTSettingsExtractor( serverlessLog(`WARNING: ${warningMessage}`) } - return { unsupportedAuth: true } + return { + unsupportedAuth: true, + } } const buildSuccessResult = (authorizerName) => ({ authorizerName }) diff --git a/src/lambda/handler-runner/child-process-runner/ChildProcessRunner.js b/src/lambda/handler-runner/child-process-runner/ChildProcessRunner.js index dcc81d652..5570997b9 100644 --- a/src/lambda/handler-runner/child-process-runner/ChildProcessRunner.js +++ b/src/lambda/handler-runner/child-process-runner/ChildProcessRunner.js @@ -1,7 +1,9 @@ -import path from 'node:path' +import { dirname, resolve } from 'node:path' +import { fileURLToPath } from 'node:url' import { execaNode } from 'execa' -const childProcessHelperPath = path.resolve(__dirname, 'childProcessHelper.js') +const __dirname = dirname(fileURLToPath(import.meta.url)) +const childProcessHelperPath = resolve(__dirname, 'childProcessHelper.js') export default class ChildProcessRunner { #allowCache = false @@ -43,10 +45,10 @@ export default class ChildProcessRunner { }, ) - const message = new Promise((resolve, reject) => { + const message = new Promise((res, rej) => { childProcess.on('message', (data) => { - if (data.error) reject(data.error) - else resolve(data) + if (data.error) rej(data.error) + else res(data) }) }).finally(() => { childProcess.kill() diff --git a/src/lambda/handler-runner/python-runner/PythonRunner.js b/src/lambda/handler-runner/python-runner/PythonRunner.js index 805e01e5c..d04219e97 100644 --- a/src/lambda/handler-runner/python-runner/PythonRunner.js +++ b/src/lambda/handler-runner/python-runner/PythonRunner.js @@ -1,13 +1,16 @@ import { spawn } from 'node:child_process' import { EOL, platform } from 'node:os' -import { delimiter, join, relative, resolve } from 'node:path' +import { delimiter, dirname, join, relative, resolve } from 'node:path' import process, { cwd } from 'node:process' import readline from 'node:readline' +import { fileURLToPath } from 'node:url' const { parse, stringify } = JSON const { assign } = Object const { has } = Reflect +const __dirname = dirname(fileURLToPath(import.meta.url)) + export default class PythonRunner { #allowCache = false #env = null diff --git a/src/lambda/handler-runner/ruby-runner/RubyRunner.js b/src/lambda/handler-runner/ruby-runner/RubyRunner.js index e260f6ef6..c8cd9cc35 100644 --- a/src/lambda/handler-runner/ruby-runner/RubyRunner.js +++ b/src/lambda/handler-runner/ruby-runner/RubyRunner.js @@ -1,16 +1,19 @@ import { EOL, platform } from 'node:os' -import { relative, resolve } from 'node:path' +import { dirname, relative, resolve } from 'node:path' import { cwd } from 'node:process' +import { fileURLToPath } from 'node:url' import { execa } from 'execa' const { parse, stringify } = JSON const { has } = Reflect +const __dirname = dirname(fileURLToPath(import.meta.url)) + export default class RubyRunner { + #allowCache = false #env = null #handlerName = null #handlerPath = null - #allowCache = false constructor(funOptions, env, allowCache, v3Utils) { const { handlerName, handlerPath } = funOptions diff --git a/src/lambda/handler-runner/worker-thread-runner/WorkerThreadRunner.js b/src/lambda/handler-runner/worker-thread-runner/WorkerThreadRunner.js index 39fb91939..e415c847f 100644 --- a/src/lambda/handler-runner/worker-thread-runner/WorkerThreadRunner.js +++ b/src/lambda/handler-runner/worker-thread-runner/WorkerThreadRunner.js @@ -1,6 +1,8 @@ -import { resolve } from 'node:path' +import { dirname, resolve } from 'node:path' +import { fileURLToPath } from 'node:url' import { MessageChannel, Worker } from 'node:worker_threads' +const __dirname = dirname(fileURLToPath(import.meta.url)) const workerThreadHelperPath = resolve(__dirname, './workerThreadHelper.js') export default class WorkerThreadRunner { @@ -34,18 +36,18 @@ export default class WorkerThreadRunner { } run(event, context) { - return new Promise((_resolve, reject) => { + return new Promise((res, rej) => { const { port1, port2 } = new MessageChannel() port1 - .on('message', _resolve) + .on('message', res) // emitted if the worker thread throws an uncaught exception. // In that case, the worker will be terminated. - .on('error', reject) + .on('error', rej) // TODO .on('exit', (code) => { if (code !== 0) { - reject(new Error(`Worker stopped with exit code ${code}`)) + rej(new Error(`Worker stopped with exit code ${code}`)) } })