Skip to content

Commit

Permalink
perf: create instance in worker thread helper module scope
Browse files Browse the repository at this point in the history
  • Loading branch information
dnalborczyk committed Sep 10, 2022
1 parent ad6833a commit 53a799e
Showing 1 changed file with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@ import InProcessRunner from '../in-process-runner/index.js'

const { functionKey, handler, servicePath, timeout, codeDir } = workerData

const inProcessRunner = new InProcessRunner(
{
codeDir,
functionKey,
handler,
servicePath,
timeout,
},
env,
)

parentPort.on('message', async (messageData) => {
const { context, event, port } = messageData

// TODO we could probably cache this in the module scope?
const inProcessRunner = new InProcessRunner(
{
codeDir,
functionKey,
handler,
servicePath,
timeout,
},
env,
)

let result

try {
Expand Down

0 comments on commit 53a799e

Please sign in to comment.