Skip to content

Report runtime init errors to localstack #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 29, 2023

Conversation

dominikschubert
Copy link
Member

Changes

  • Fix shutdown and remove unused profiler (Previously the http server was blocking until the process was killed. Now it is properly ended after receiving a registered signal, i.e. SIGINT or SIGTERM)
  • Report runtime init error back to localstack

Example for the init report arriving at localstack

2023-03-29T21:53:39.854 WARNING --- [   asgi_gw_1] localstack.services.awslambda.invocation.executor_endpoint : Execution environment startup failed: {"errorMessage": "ooooooh no", "errorType": "Exception", "stackTrace": ["  File \"/var/lang/lib/python3.8/imp.py\", line 234, in load_module\n    return load_source(name, filename, file)\n", "  File \"/var/lang/lib/python3.8/imp.py\", line 171, in load_source\n    module = _load(spec)\n", "  File \"<frozen importlib._bootstrap>\", line 702, in _load\n", "  File \"<frozen importlib._bootstrap>\", line 671, in _load_unlocked\n", "  File \"<frozen importlib._bootstrap_external>\", line 843, in exec_module\n", "  File \"<frozen importlib._bootstrap>\", line 219, in _call_with_frames_removed\n", "  File \"/var/task/handler.py\", line 4, in <module>\n    raise Exception(\"ooooooh no\")\n"]}

The init error above is caused by directly raising an exception outside of the python handler.

Copy link
Member

@joe4dev joe4dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error reporting works nicely 👍 and is very useful.

Tested both cases:
a) provoking error from RIE by omitting "_HANDLER"
b) raising Error in Nodejs runtime outside handler function provides a helpful error message in LocalStack now:

2023-03-29T22:40:07.439  WARN --- [   asgi_gw_0] l.s.a.i.executor_endpoint  : Execution environment startup failed: {"errorType":"Error","errorMessage":"MY RUNTIME BREAKS NOW!","trace":["Error: MY RUNTIME BREAKS NOW!","    at Object.<anonymous> (/var/task/index.js:19:7)","    at Module._compile (internal/modules/cjs/loader.js:1114:14)","    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)","    at Module.load (internal/modules/cjs/loader.js:979:32)","    at Function.Module._load (internal/modules/cjs/loader.js:819:12)","    at Module.require (internal/modules/cjs/loader.js:1003:19)","    at require (internal/modules/cjs/helpers.js:107:18)","    at _tryRequireFile (/var/runtime/UserFunction.js:72:32)","    at _tryRequire (/var/runtime/UserFunction.js:160:20)","    at _loadUserApp (/var/runtime/UserFunction.js:219:12)"]}

@dominikschubert dominikschubert merged commit 5fbd26b into localstack Mar 29, 2023
@dominikschubert dominikschubert deleted the init-error-reporting branch March 29, 2023 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants