Skip to content

Improve Parse action error handling #7

@stas-fomenko

Description

@stas-fomenko

Description:

Implement error handling, throw some meanungfull error when:

  1. no file comes from previous step UPD: FIXED
  2. not an .EDI file comes from previous step
AR: no error thrown
LOGS: 
[2021-03-09 18:10:18.303]: [INFO  tini (1)] Spawned child process '/run.sh' with pid '6'
[2021-03-09 18:10:18.304]: Starting application in apprunner...
[2021-03-09 18:10:18.322]: node: /usr/lib/libstdc++.so.6: no version information available (required by node)
[2021-03-09 18:10:18.322]: node: /usr/lib/libstdc++.so.6: no version information available (required by node)
[2021-03-09 18:10:18.322]: node: /usr/lib/libstdc++.so.6: no version information available (required by node)
[2021-03-09 18:10:18.322]: node: /usr/lib/libstdc++.so.6: no version information available (required by node)
[2021-03-09 18:10:18.322]: node: /usr/lib/libstdc++.so.6: no version information available (required by node)
[2021-03-09 18:10:18.322]: node: /usr/lib/libstdc++.so.6: no version information available (required by node)
[2021-03-09 18:10:18.322]: Will try to start app at /home/apprunner
[2021-03-09 18:10:18.322]: node: /usr/lib/libstdc++.so.6: no version information available (required by node)
[2021-03-09 18:10:18.322]: node: /usr/lib/libstdc++.so.6: no version information available (required by node)
[2021-03-09 18:10:19.348]: Received step data
[2021-03-09 18:10:19.349]: Component path is: /home/apprunner
[2021-03-09 18:10:19.349]: Root files: [".circleci",".editorconfig",".eslintrc.js",".gitattributes",".gitignore",".heroku",".npmrc",".profile.d",".release","CHANGELOG.md","LICENSE","README.md","component.json","lib","logo.png","node_modules","package-lock.json","package.json","sail.sh","samples","serve.sh","spec"]
[2021-03-09 18:10:19.350]: Triggers: []
[2021-03-09 18:10:19.350]: Actions: ["parse"]
[2021-03-09 18:10:19.350]: Successfully loaded /home/apprunner/component.json
[2021-03-09 18:10:19.351]: About to initialize component for execution
[2021-03-09 18:10:19.352]: Trying to find module at: /home/apprunner/lib/actions/parse.js
[2021-03-09 18:10:19.380]: Start listening for messages on 5a82f375a847400007c8d569:60479da183125a00118f684e/ordinary:step_7:messages
[2021-03-09 18:10:19.380]: invokeModuleFunction – init is not found
[2021-03-09 18:10:19.380]: Component execution initialized successfully
[2021-03-09 18:10:22.802]: Message received
[2021-03-09 18:10:22.815]: No object id header so not lightweight.
[2021-03-09 18:10:22.815]: Trigger or action: parse
[2021-03-09 18:10:22.815]: No object id header so not lightweight.
[2021-03-09 18:10:22.815]: No object id header so not lightweight.
[2021-03-09 18:10:22.815]: processMessage received
[2021-03-09 18:10:22.815]: Going to check if passthrough for step is lightweight. { stepId: 'step_1' }
[2021-03-09 18:10:22.815]: Going to check if passthrough for step is lightweight. { stepId: 'step_6' }
[2021-03-09 18:10:22.815]: Trying to find module at: /home/apprunner/lib/actions/parse.js
[2021-03-09 18:10:22.815]: Going to check if incoming message body is lightweight.
[2021-03-09 18:10:22.815]: Checking if incoming messages is lightweight...
[2021-03-09 18:10:22.815]: Checking if incoming messages is lightweight...
[2021-03-09 18:10:22.815]: Checking if incoming messages is lightweight...
[2021-03-09 18:10:22.832]: Starting parse action...
[2021-03-09 18:10:22.832]: Attachment found
[2021-03-09 18:10:22.832]: Sending GET request to provided url
[2021-03-09 18:10:22.837]: Message #1 ack
[2021-03-09 18:10:22.848]: processMessage emit end
[2021-03-09 18:10:22.867]: Have got response status=200
[2021-03-09 18:10:22.867]: Parsing EDIFACT...
[2021-03-09 18:10:22.868]: at Request.emit (events.js:327:22)
[2021-03-09 18:10:22.868]: at Object.onceWrapper (events.js:421:28)
[2021-03-09 18:10:22.868]: at processTicksAndRejections (internal/process/task_queues.js:80:21)
[2021-03-09 18:10:22.868]: at Parser.write (/home/apprunner/node_modules/edifact/parser.js:151:29)
[2021-03-09 18:10:22.868]: at Object.invalidControlAfterSegment (/home/apprunner/node_modules/edifact/parser.js:237:12)
[2021-03-09 18:10:22.868]: at IncomingMessage.emit (events.js:327:22)
[2021-03-09 18:10:22.868]: at endReadableNT (internal/streams/readable.js:1327:12)
[2021-03-09 18:10:22.868]: (node:6) UnhandledPromiseRejectionWarning: Error: Invalid character � after reading segment name
[2021-03-09 18:10:22.868]: at IncomingMessage.<anonymous> (/home/apprunner/node_modules/request/request.js:1076:12)
[2021-03-09 18:10:22.868]: at Request.<anonymous> (/home/apprunner/lib/actions/parse.js:83:14)
[2021-03-09 18:10:22.868]: (Use `node --trace-warnings ...` to show where the warning was created)
[2021-03-09 18:10:22.868]: (node:6) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
[2021-03-09 18:10:22.868]: (node:6) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
[2021-03-09 18:10:54.573]: Received SIGTERM
[2021-03-09 18:10:54.573]: Disconnecting, 0 messages in processing
[2021-03-09 18:10:54.573]: scheduleShutdown – about to shutdown immediately
[2021-03-09 18:10:54.573]: Disconnecting...
[2021-03-09 18:10:54.573]: Close AMQP connections
[2021-03-09 18:10:54.589]: Successfully disconnected
[2021-03-09 18:10:54.589]: [INFO  tini (1)] Main child exited normally (with status '0')
[2021-03-09 18:10:54.589]: Successfully closed AMQP connections
[2021-03-09 18:11:28.236]: node: /usr/lib/libstdc++.so.6: no version information available (required by node)
[2021-03-09 18:11:28.236]: [INFO  tini (1)] Spawned child process '/run.sh' with pid '6'
[2021-03-09 18:11:28.236]: Starting application in apprunner...
[2021-03-09 18:11:28.236]: node: /usr/lib/libstdc++.so.6: no version information available (required by node)
[2021-03-09 18:11:28.236]: Will try to start app at /home/apprunner
[2021-03-09 18:11:28.236]: node: /usr/lib/libstdc++.so.6: no version information available (required by node)
[2021-03-09 18:11:28.236]: node: /usr/lib/libstdc++.so.6: no version information available (required by node)
[2021-03-09 18:11:28.236]: node: /usr/lib/libstdc++.so.6: no version information available (required by node)
[2021-03-09 18:11:28.236]: node: /usr/lib/libstdc++.so.6: no version information available (required by node)
[2021-03-09 18:11:28.236]: node: /usr/lib/libstdc++.so.6: no version information available (required by node)
[2021-03-09 18:11:28.236]: node: /usr/lib/libstdc++.so.6: no version information available (required by node)
[2021-03-09 18:11:29.097]: Root files: [".circleci",".editorconfig",".eslintrc.js",".gitattributes",".gitignore",".heroku",".npmrc",".profile.d",".release","CHANGELOG.md","LICENSE","README.md","component.json","lib","logo.png","node_modules","package-lock.json","package.json","sail.sh","samples","serve.sh","spec"]
[2021-03-09 18:11:29.097]: Received step data
[2021-03-09 18:11:29.097]: Component path is: /home/apprunner
[2021-03-09 18:11:29.098]: Successfully loaded /home/apprunner/component.json
[2021-03-09 18:11:29.098]: Triggers: []
[2021-03-09 18:11:29.098]: Actions: ["parse"]
[2021-03-09 18:11:29.102]: About to initialize component for execution
[2021-03-09 18:11:29.102]: Trying to find module at: /home/apprunner/lib/actions/parse.js
[2021-03-09 18:11:29.133]: Start listening for messages on 5a82f375a847400007c8d569:60479da183125a00118f684e/ordinary:step_7:messages
[2021-03-09 18:11:29.133]: Component execution initialized successfully
[2021-03-09 18:11:29.133]: invokeModuleFunction – init is not found
[2021-03-09 18:12:10.001]: Disconnecting...
[2021-03-09 18:12:10.001]: Disconnecting, 0 messages in processing
[2021-03-09 18:12:10.001]: Close AMQP connections
[2021-03-09 18:12:10.001]: Received SIGTERM
[2021-03-09 18:12:10.001]: scheduleShutdown – about to shutdown immediately
[2021-03-09 18:12:10.012]: Successfully disconnected
[2021-03-09 18:12:10.012]: Successfully closed AMQP connections
[2021-03-09 18:12:10.026]: [INFO  tini (1)] Main child exited normally (with status '0')
  1. more then 1 EDI file comes from previous step

so, improve error handling in order to allow the action to work only with 1 file/execution (sample retrieve) and it must be .EDI file

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions