serverless-heaven / serverless-webpack

Serverless plugin to bundle your lambdas with Webpack
MIT License
1.72k stars 415 forks source link

lambda output missing when using invoke inside pm2 #464

Open SET001 opened 5 years ago

SET001 commented 5 years ago

This is a Bug Report

Description

For bug reports:

PM2           | Change detected on path src/index.ts for app my-service - restarting
PM2           | Stopping app:my-service id:0
PM2           | App [my-service:0] exited with code [0] via signal [SIGINT]
PM2           | pid=81513 msg=process killed
PM2           | App [my-service:0] starting in -fork mode-
PM2           | App [my-service:0] online
0|my-service  | > aws-nodejs-typescript@1.0.0 invoke:hello /home/set/www/cloudbeds/apiTest
0|my-service  | > sls invoke local -f hello
0|my-service  | Serverless: Bundling with Webpack...
0|my-service  | Time: 2171ms
0|my-service  | Built at: 11/22/2018 11:36:50 PM
0|my-service  |            Asset      Size     Chunks             Chunk Names
0|my-service  |       handler.js  1.34 MiB    handler  [emitted]  handler
0|my-service  |   handler.js.map  1.13 MiB    handler  [emitted]  handler
0|my-service  |     src/index.js  1.46 MiB  src/index  [emitted]  src/index
0|my-service  | src/index.js.map  1.26 MiB  src/index  [emitted]  src/index
0|my-service  | Entrypoint handler = handler.js handler.js.map
0|my-service  | Entrypoint src/index = src/index.js src/index.js.map
0|my-service  | [0] multi ./source-map-install.js ./src/index.ts 40 bytes {src/index} [built]
0|my-service  | [./node_modules/buffer-from/index.js] 1.56 KiB {src/index} [built]
0|my-service  | [./node_modules/request-promise-core/configure/request2.js] 1.75 KiB {handler} {src/index} [built]
0|my-service  | [./node_modules/request-promise-native/lib/rp.js] 531 bytes {handler} {src/index} [built]
0|my-service  | [./node_modules/request/index.js] 3.88 KiB {handler} {src/index} [built]
0|my-service  | [./node_modules/source-map-support/source-map-support.js] 17.5 KiB {src/index} [built]
0|my-service  | [./node_modules/source-map/source-map.js] 405 bytes {src/index} [built]
0|my-service  | [./node_modules/stealthy-require/lib/index.js] 2.34 KiB {handler} {src/index} [built]
0|my-service  | [./node_modules/tough-cookie/lib/cookie.js] 38.6 KiB {handler} {src/index} [built]
0|my-service  | [./node_modules/webpack/buildin/module.js] (webpack)/buildin/module.js 497 bytes {handler} {src/index} [built]
0|my-service  | [./source-map-install.js] 41 bytes {src/index} [built]
0|my-service  | [./src/index.ts] 1.03 KiB {handler} {src/index} [built]
0|my-service  | [./src/reservations.ts] 227 bytes {handler} {src/index} [built]
0|my-service  | [fs] external "fs" 42 bytes {handler} {src/index} [built]
0|my-service  | [module] external "module" 42 bytes {src/index} [optional] [built]
0|my-service  |     + 213 hidden modules
set@set-home ~/www/cloudbeds/apiTest $ sls invoke local -f hello
Serverless: Bundling with Webpack...
Time: 2164ms
Built at: 11/22/2018 11:25:09 PM
           Asset      Size     Chunks             Chunk Names
      handler.js  1.34 MiB    handler  [emitted]  handler
  handler.js.map  1.13 MiB    handler  [emitted]  handler
    src/index.js  1.46 MiB  src/index  [emitted]  src/index
src/index.js.map  1.26 MiB  src/index  [emitted]  src/index
Entrypoint handler = handler.js handler.js.map
Entrypoint src/index = src/index.js src/index.js.map
[0] multi ./source-map-install.js ./src/index.ts 40 bytes {src/index} [built]
[./node_modules/buffer-from/index.js] 1.56 KiB {src/index} [built]
[./node_modules/request-promise-core/configure/request2.js] 1.75 KiB {handler} {src/index} [built]
[./node_modules/request-promise-native/lib/rp.js] 531 bytes {handler} {src/index} [built]
[./node_modules/request/index.js] 3.88 KiB {handler} {src/index} [built]
[./node_modules/source-map-support/source-map-support.js] 17.5 KiB {src/index} [built]
[./node_modules/source-map/source-map.js] 405 bytes {src/index} [built]
[./node_modules/stealthy-require/lib/index.js] 2.34 KiB {handler} {src/index} [built]
[./node_modules/tough-cookie/lib/cookie.js] 38.6 KiB {handler} {src/index} [built]
[./node_modules/webpack/buildin/module.js] (webpack)/buildin/module.js 497 bytes {handler} {src/index} [built]
[./source-map-install.js] 41 bytes {src/index} [built]
[./src/index.ts] 1.03 KiB {handler} {src/index} [built]
[./src/reservations.ts] 227 bytes {handler} {src/index} [built]
[fs] external "fs" 42 bytes {handler} {src/index} [built]
[module] external "module" 42 bytes {src/index} [optional] [built]
    + 213 hidden modules
Serverless: INVOKING INVOKE
{
    "statusCode": 200,
    "body": "{\"message\":\"\\\"ok\\\"\",\"input\":\"\"}"
}
  "scripts": {
    "invoke:hello": "sls invoke local -f hello"
  },

Additional Data

not sure either this is pm2 issue or related to this plugin

SET001 commented 5 years ago

I'm using pm2 here because sls invoke local -f hello --watch will crash the process on errors and I would have to restart it over and over...

HyperBrain commented 5 years ago

Hi @SET001 . Can you check if both, stderr and stdout are printed properly within PM2? It is quite strange, that the compile output is visible, but the function output is not. As far as I know, they only use standard output mechanisms.