Skip to content

Commit 17e22e1

Browse files
author
Gideon Pyzer
committed
Don't use static file server for lambdas
1 parent a76420f commit 17e22e1

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

packages/renderer-aws-lambda/src/create-aws-lambda-renderer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const createChromeAWSLambdaRenderer = () => async (event) => {
5454
}
5555
const target = createChromeAppTarget({
5656
baseUrl: event.baseUrl,
57+
useStaticServer: false,
5758
});
5859
try {
5960
await target.start({

packages/target-chrome-app/src/create-chrome-app-target.js

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@ const {
99
} = require('@loki/core');
1010
const { createChromeTarget } = require('@loki/target-chrome-core');
1111

12-
function createChromeAppTarget({
13-
baseUrl = 'http://localhost:6006',
14-
chromeFlags = ['--headless', '--disable-gpu', '--hide-scrollbars'],
15-
}) {
16-
let instance;
17-
let staticServer;
12+
function getStaticServerConfig(baseUrl) {
1813
let staticServerPath;
1914
let staticServerPort;
2015

@@ -39,8 +34,27 @@ function createChromeAppTarget({
3934
}
4035
}
4136

37+
return {
38+
staticServerPath,
39+
staticServerPort,
40+
isLocalFile,
41+
chromeUrl,
42+
};
43+
}
44+
45+
function createChromeAppTarget({
46+
baseUrl = 'http://localhost:6006',
47+
useStaticServer = true,
48+
chromeFlags = ['--headless', '--disable-gpu', '--hide-scrollbars'],
49+
}) {
50+
let instance;
51+
let staticServer;
52+
53+
const { staticServerPath, staticServerPort, isLocalFile, chromeUrl } =
54+
getStaticServerConfig(baseUrl);
55+
4256
async function start(options = {}) {
43-
if (isLocalFile) {
57+
if (useStaticServer && isLocalFile) {
4458
staticServer = createStaticServer(staticServerPath);
4559
staticServer.listen(staticServerPort);
4660
debug(`Starting static file server at ${chromeUrl}`);
@@ -66,7 +80,7 @@ function createChromeAppTarget({
6680
debug('No chrome instance to kill');
6781
}
6882

69-
if (staticServer) {
83+
if (useStaticServer && staticServer) {
7084
staticServer.close();
7185
}
7286
}
@@ -86,7 +100,12 @@ function createChromeAppTarget({
86100
return client;
87101
}
88102

89-
return createChromeTarget(start, stop, createNewDebuggerInstance, chromeUrl);
103+
return createChromeTarget(
104+
start,
105+
stop,
106+
createNewDebuggerInstance,
107+
useStaticServer ? chromeUrl : baseUrl
108+
);
90109
}
91110

92111
module.exports = createChromeAppTarget;

0 commit comments

Comments
 (0)