Skip to content

Commit 386b189

Browse files
Merge pull request #73 from ServerlessLife/additional-node-options
fix: Use NODE_OPTIONS=--enable-source-maps only localy
2 parents 1c90816 + 5c34f25 commit 386b189

File tree

7 files changed

+34
-19
lines changed

7 files changed

+34
-19
lines changed

.github/workflows/pull-request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
# pull_request:
66
# branches:
77
# - main
8-
pull_request_target:
8+
pull_request_review:
99
branches:
1010
- main
1111

.vitepress/config.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ export default defineConfig({
7474
{ text: 'CLI Parameters', link: '#cli-parameters' },
7575
{ text: 'Configuration file', link: '#configuration-file' },
7676
{ text: 'Debugging', link: '#debugging' },
77+
{ text: 'Removing', link: '#removing' },
7778
{ text: 'Development Process', link: '#development-process' },
7879
{ text: 'Observability Mode', link: '#observability-mode' },
7980
{ text: 'Monorepo', link: '#monorepo-setup' },
80-
{ text: 'Removing', link: '#removing' },
8181
],
8282
},
8383
{

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -167,21 +167,9 @@ Now, you have to press F5 or press Run -> Start Debugging, and you can set break
167167

168168
For other tools, please send documentation to include here. WebStorm instructions are especially needed.
169169

170-
## Development Process
171-
172-
Since you deploy code to a real AWS account, it's best to have a dedicated environment only for yourself. It could be your personal environment or an environment created for a feature. That is [common practice when developing serverless systems](https://theburningmonk.com/2019/09/why-you-should-use-temporary-stacks-when-you-do-serverless/). If that's not feasible due to organizational or technical reasons, use Observability Mode.
173-
174-
## Observability Mode
175-
176-
In Observability Mode, Lambda Live Debugger intercepts requests and sends them to your computer without waiting for a response. The Lambda continues as usual. The response from your machine is ignored. This mode can be used in the development, testing, or even, if you are adventurous, production environment. It samples requests every 3 seconds by default (configurable with an `interval` setting) to avoid overloading the system.
177-
178-
## Monorepo Setup
179-
180-
Set the `subfolder` parameter if your framework is in a subfolder.
181-
182170
## Removing
183171

184-
To remove Lambda Live Debugger from your AWS account
172+
When you no longer want to debug and want Lambda to execute the code deployed to the cloud, you need to remove the Lambda Live Debugger:
185173

186174
```
187175
lld -r
@@ -195,6 +183,18 @@ To also remove the Layer:
195183
lld -r=all
196184
```
197185

186+
## Development Process
187+
188+
Since you deploy code to a real AWS account, it's best to have a dedicated environment only for yourself. It could be your personal environment or an environment created for a feature. That is [common practice when developing serverless systems](https://theburningmonk.com/2019/09/why-you-should-use-temporary-stacks-when-you-do-serverless/). If that's not feasible due to organizational or technical reasons, use Observability Mode.
189+
190+
## Observability Mode
191+
192+
In Observability Mode, Lambda Live Debugger intercepts requests and sends them to your computer without waiting for a response. The Lambda continues as usual. The response from your machine is ignored. This mode can be used in the development, testing, or even, if you are adventurous, production environment. It samples requests every 3 seconds by default (configurable with an `interval` setting) to avoid overloading the system.
193+
194+
## Monorepo Setup
195+
196+
Set the `subfolder` parameter if your framework is in a subfolder.
197+
198198
## Frameworks
199199

200200
### AWS CDK v2

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"lint": "eslint . --fix",
4242
"prettier": "prettier . --write",
4343
"prepare": "husky",
44-
"add-bang": "sed -i '1s|^|#!/usr/bin/env node\\n|' ./dist/lldebugger.mjs",
44+
"add-bang": "printf '#!/usr/bin/env node\\n%s' \"$(cat ./dist/lldebugger.mjs)\" > ./dist/lldebugger.mjs.tmp && mv ./dist/lldebugger.mjs.tmp ./dist/lldebugger.mjs",
4545
"build": "tsc -p tsconfig.build.json && cp src/nodeWorkerRunner.mjs dist && cp src/frameworks/cdkFrameworkWorker.mjs dist/frameworks && node fix-imports.js && npm run add-bang && npm run bundle-extension",
4646
"bundle-extension": "cd src/extension && npm run build && cd ../../",
4747
"deploy-github-role": "aws cloudformation deploy --stack-name lld-deploy-role --template-file cloudformation/gitHubDeployRole.yaml --capabilities CAPABILITY_IAM CAPABILITY_NAMED_IAM --profile lldebugger",

src/infraDeploy.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,6 @@ function getEnvironmentVarablesForDebugger(
562562
return {
563563
LLD_FUNCTION_ID: functionId,
564564
AWS_LAMBDA_EXEC_WRAPPER: '/opt/lld-wrapper',
565-
NODE_OPTIONS: '--enable-source-maps',
566565
LLD_DEBUGGER_ID: Configuration.config.debuggerId,
567566
LLD_INITIAL_TIMEOUT: timeout ? timeout.toString() : '-1', // should never be negative
568567
LLD_OBSERVABLE_MODE: Configuration.config.observable ? 'true' : 'false',

src/nodeWorker.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,15 @@ async function runInWorker(input: {
3434
);
3535

3636
if (!worker) {
37+
const environment = input.environment;
38+
addEnableSourceMapsToEnv(environment);
39+
3740
worker = startWorker({
3841
handler: func.handler ?? 'handler',
3942
artifactFile: input.artifactFile,
4043
workerId: input.fuctionRequest.workerId,
4144
functionId: input.fuctionRequest.functionId,
42-
environment: input.environment,
45+
environment,
4346
verbose: Configuration.config.verbose,
4447
});
4548
worker.used = false;
@@ -85,6 +88,20 @@ async function runInWorker(input: {
8588
});
8689
}
8790

91+
/**
92+
* Add NODE_OPTIONS: --enable-source-maps to the environment variables
93+
* @param environment
94+
*/
95+
function addEnableSourceMapsToEnv(environment: {
96+
[key: string]: string | undefined;
97+
}) {
98+
const nodeOptions = environment.NODE_OPTIONS || '';
99+
if (!nodeOptions.includes('--enable-source-maps')) {
100+
environment.NODE_OPTIONS =
101+
nodeOptions + (nodeOptions ? ' ' : '') + '--enable-source-maps';
102+
}
103+
}
104+
88105
type WorkerRequest = {
89106
handler: string;
90107
artifactFile: string;

test/utils/expectInfraDeployed.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export async function expectInfraDeployed(lambdaName: any) {
1515
LLD_DEBUGGER_ID: expect.any(String),
1616
LLD_FUNCTION_ID: expect.any(String),
1717
LLD_INITIAL_TIMEOUT: expect.any(String),
18-
NODE_OPTIONS: '--enable-source-maps',
1918
});
2019

2120
const initialTimeout = parseInt(

0 commit comments

Comments
 (0)