lambda-live-debugger 1.1.3 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -74,10 +74,10 @@ export default defineConfig({
74
74
  { text: 'CLI Parameters', link: '#cli-parameters' },
75
75
  { text: 'Configuration file', link: '#configuration-file' },
76
76
  { text: 'Debugging', link: '#debugging' },
77
+ { text: 'Removing', link: '#removing' },
77
78
  { text: 'Development Process', link: '#development-process' },
78
79
  { text: 'Observability Mode', link: '#observability-mode' },
79
80
  { text: 'Monorepo', link: '#monorepo-setup' },
80
- { text: 'Removing', link: '#removing' },
81
81
  ],
82
82
  },
83
83
  {
package/README.md CHANGED
@@ -167,21 +167,9 @@ Now, you have to press F5 or press Run -> Start Debugging, and you can set break
167
167
 
168
168
  For other tools, please send documentation to include here. WebStorm instructions are especially needed.
169
169
 
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
-
182
170
  ## Removing
183
171
 
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:
185
173
 
186
174
  ```
187
175
  lld -r
@@ -195,6 +183,18 @@ To also remove the Layer:
195
183
  lld -r=all
196
184
  ```
197
185
 
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
+
198
198
  ## Frameworks
199
199
 
200
200
  ### AWS CDK v2
Binary file
@@ -394,7 +394,6 @@ function getEnvironmentVarablesForDebugger(functionId, timeout) {
394
394
  return {
395
395
  LLD_FUNCTION_ID: functionId,
396
396
  AWS_LAMBDA_EXEC_WRAPPER: '/opt/lld-wrapper',
397
- NODE_OPTIONS: '--enable-source-maps',
398
397
  LLD_DEBUGGER_ID: Configuration.config.debuggerId,
399
398
  LLD_INITIAL_TIMEOUT: timeout ? timeout.toString() : '-1', // should never be negative
400
399
  LLD_OBSERVABLE_MODE: Configuration.config.observable ? 'true' : 'false',
@@ -80,4 +80,4 @@ async function run() {
80
80
  await LambdaConnection.connect();
81
81
  Logger.log('Debugger started!');
82
82
  }
83
- run().catch(Logger.error);
83
+ run().catch(Logger.error);
@@ -14,12 +14,14 @@ async function runInWorker(input) {
14
14
  return new Promise((resolve, reject) => {
15
15
  let worker = workers.get(input.fuctionRequest.workerId);
16
16
  if (!worker) {
17
+ const environment = input.environment;
18
+ addEnableSourceMapsToEnv(environment);
17
19
  worker = startWorker({
18
20
  handler: func.handler ?? 'handler',
19
21
  artifactFile: input.artifactFile,
20
22
  workerId: input.fuctionRequest.workerId,
21
23
  functionId: input.fuctionRequest.functionId,
22
- environment: input.environment,
24
+ environment,
23
25
  verbose: Configuration.config.verbose,
24
26
  });
25
27
  worker.used = false;
@@ -54,6 +56,17 @@ async function runInWorker(input) {
54
56
  });
55
57
  });
56
58
  }
59
+ /**
60
+ * Add NODE_OPTIONS: --enable-source-maps to the environment variables
61
+ * @param environment
62
+ */
63
+ function addEnableSourceMapsToEnv(environment) {
64
+ const nodeOptions = environment.NODE_OPTIONS || '';
65
+ if (!nodeOptions.includes('--enable-source-maps')) {
66
+ environment.NODE_OPTIONS =
67
+ nodeOptions + (nodeOptions ? ' ' : '') + '--enable-source-maps';
68
+ }
69
+ }
57
70
  /**
58
71
  * Start a new Node.js Worker Thread
59
72
  * @param input
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lambda-live-debugger",
3
- "version": "1.1.3",
3
+ "version": "1.2.0",
4
4
  "type": "module",
5
5
  "description": "Debug Lambda functions locally like it is running in the cloud",
6
6
  "repository": {
@@ -41,7 +41,7 @@
41
41
  "lint": "eslint . --fix",
42
42
  "prettier": "prettier . --write",
43
43
  "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",
45
45
  "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",
46
46
  "bundle-extension": "cd src/extension && npm run build && cd ../../",
47
47
  "deploy-github-role": "aws cloudformation deploy --stack-name lld-deploy-role --template-file cloudformation/gitHubDeployRole.yaml --capabilities CAPABILITY_IAM CAPABILITY_NAMED_IAM --profile lldebugger",