lambda-live-debugger 1.1.3 → 1.2.1
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.
- package/.vitepress/config.mts +1 -1
- package/README.md +13 -13
- package/dist/extension/extension.zip +0 -0
- package/dist/extension/nodejs/node_modules/interceptor.js +51 -8
- package/dist/extension/nodejs/node_modules/interceptor.js.map +3 -3
- package/dist/infraDeploy.mjs +46 -10
- package/dist/lldebugger.mjs +1 -1
- package/dist/logger.d.ts +6 -0
- package/dist/logger.mjs +8 -0
- package/dist/nodeWorker.mjs +14 -1
- package/package.json +2 -2
package/.vitepress/config.mts
CHANGED
|
@@ -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
|
-
|
|
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
|
|
@@ -53648,13 +53648,17 @@ function verbose(...args) {
|
|
|
53648
53648
|
function setVerbose(enabled) {
|
|
53649
53649
|
verboseEnabled = enabled;
|
|
53650
53650
|
}
|
|
53651
|
+
function isVerbose() {
|
|
53652
|
+
return verboseEnabled;
|
|
53653
|
+
}
|
|
53651
53654
|
var Logger = {
|
|
53652
53655
|
log,
|
|
53653
53656
|
error,
|
|
53654
53657
|
warn,
|
|
53655
53658
|
important,
|
|
53656
53659
|
verbose,
|
|
53657
|
-
setVerbose
|
|
53660
|
+
setVerbose,
|
|
53661
|
+
isVerbose
|
|
53658
53662
|
};
|
|
53659
53663
|
|
|
53660
53664
|
// ../ioTService.ts
|
|
@@ -53764,6 +53768,7 @@ var IoTService = {
|
|
|
53764
53768
|
var workerId = import_crypto5.default.randomBytes(16).toString("hex");
|
|
53765
53769
|
var topic = `${process.env.LLD_DEBUGGER_ID}/events/${workerId}`;
|
|
53766
53770
|
var ORIGINAL_HANDLER_KEY = "ORIGINAL_HANDLER";
|
|
53771
|
+
var originalHandlerName = process.env[ORIGINAL_HANDLER_KEY];
|
|
53767
53772
|
var observableInterval = process.env.LLD_OBSERVABLE_INTERVAL ? parseInt(process.env.LLD_OBSERVABLE_INTERVAL) : 0;
|
|
53768
53773
|
var lastObservableInvoke;
|
|
53769
53774
|
if (process.env.LLD_VERBOSE === "true") {
|
|
@@ -53838,10 +53843,47 @@ async function regularMode(context, event) {
|
|
|
53838
53843
|
return promise;
|
|
53839
53844
|
}
|
|
53840
53845
|
async function observableMode(context, event) {
|
|
53841
|
-
|
|
53842
|
-
|
|
53843
|
-
|
|
53844
|
-
|
|
53846
|
+
let regularHandler = void 0;
|
|
53847
|
+
if (process.env.LLD_INITIAL_AWS_LAMBDA_EXEC_WRAPPER) {
|
|
53848
|
+
try {
|
|
53849
|
+
Logger.log(
|
|
53850
|
+
`Another extensions exists ${process.env.LLD_INITIAL_AWS_LAMBDA_EXEC_WRAPPER}.`
|
|
53851
|
+
);
|
|
53852
|
+
const { promisify } = require("util");
|
|
53853
|
+
const exec = require("child_process").exec;
|
|
53854
|
+
const execAsync = promisify(exec);
|
|
53855
|
+
const fs = require("fs/promises");
|
|
53856
|
+
const originalScript = await fs.readFile(
|
|
53857
|
+
process.env.LLD_INITIAL_AWS_LAMBDA_EXEC_WRAPPER,
|
|
53858
|
+
"utf8"
|
|
53859
|
+
);
|
|
53860
|
+
Logger.verbose("Original script", originalScript);
|
|
53861
|
+
const script = `export _HANDLER=${process.env.ORIGINAL_HANDLER}
|
|
53862
|
+
${originalScript}
|
|
53863
|
+
echo _HANDLER=$_HANDLER`;
|
|
53864
|
+
Logger.verbose("Execute script", script);
|
|
53865
|
+
const response2 = await execAsync(script);
|
|
53866
|
+
Logger.verbose(`Output of the script: ${response2.stdout}`);
|
|
53867
|
+
const handlerLine = response2.stdout.split("\n").find((line) => line.startsWith("_HANDLER"));
|
|
53868
|
+
const oldHandler = handlerLine.split("=")[1];
|
|
53869
|
+
Logger.verbose(`Getting handler "${oldHandler}" for another extension`);
|
|
53870
|
+
regularHandler = async () => {
|
|
53871
|
+
const handler2 = await getOriginalHandler(oldHandler);
|
|
53872
|
+
return await handler2(event, context);
|
|
53873
|
+
};
|
|
53874
|
+
} catch (e) {
|
|
53875
|
+
Logger.error(
|
|
53876
|
+
`Error while running the initial AWS_LAMBDA_EXEC_WRAPPER: ${e.message}`,
|
|
53877
|
+
e
|
|
53878
|
+
);
|
|
53879
|
+
}
|
|
53880
|
+
}
|
|
53881
|
+
if (!regularHandler) {
|
|
53882
|
+
regularHandler = async () => {
|
|
53883
|
+
const handler2 = await getOriginalHandler(originalHandlerName);
|
|
53884
|
+
return await handler2(event, context);
|
|
53885
|
+
};
|
|
53886
|
+
}
|
|
53845
53887
|
const observableHandler = async () => {
|
|
53846
53888
|
if (observableInterval > 0) {
|
|
53847
53889
|
if (lastObservableInvoke) {
|
|
@@ -53878,13 +53920,14 @@ async function observableMode(context, event) {
|
|
|
53878
53920
|
const response = await regularHandlerPromise;
|
|
53879
53921
|
return response;
|
|
53880
53922
|
}
|
|
53881
|
-
async function getOriginalHandler() {
|
|
53923
|
+
async function getOriginalHandler(originalHandlerName2) {
|
|
53924
|
+
Logger.verbose("Original handler:", originalHandlerName2);
|
|
53882
53925
|
const { load } = await Promise.resolve().then(() => __toESM(require_UserFunction()));
|
|
53883
|
-
if (
|
|
53926
|
+
if (originalHandlerName2 === void 0)
|
|
53884
53927
|
throw Error("Missing original handler");
|
|
53885
53928
|
return load(
|
|
53886
53929
|
process.env.LAMBDA_TASK_ROOT,
|
|
53887
|
-
|
|
53930
|
+
originalHandlerName2
|
|
53888
53931
|
);
|
|
53889
53932
|
}
|
|
53890
53933
|
// Annotate the CommonJS export names for ESM import in node:
|