js-ceramic icon indicating copy to clipboard operation
js-ceramic copied to clipboard

Ceramic daemon should return a promise rejection if cannot connect to ipfs node

Open Schwartz10 opened this issue 4 years ago • 5 comments

For bash scripting purposes, it would be helpful if the ceramic daemon would more gracefully fail, returning non-zero exit codes.

When the IPFS node is starting up, if we start the ceramic daemon too early, we get:

Executing command in 1 package: "ceramic daemon --ipfs-api http://localhost:5011"
(node:39087) UnhandledPromiseRejectionWarning: FetchError: request to http://localhost:5011/api/v0/id failed, reason: socket hang up
    at ClientRequest.<anonymous> (/Users/jonathanschwartz/Documents/daemon-land/js-sdk/services/api/node_modules/node-fetch/lib/index.js:1461:11)
    at ClientRequest.emit (events.js:314:20)
    at Socket.socketOnEnd (_http_client.js:493:9)
    at Socket.emit (events.js:326:22)
    at endReadableNT (_stream_readable.js:1244:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:39087) 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)
(node:39087) [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.

For some reason this still seems to register as a successfully run command. This makes it hard to gracefully script deployments.

Schwartz10 avatar Jan 14 '21 21:01 Schwartz10

Thanks for reporting this @Schwartz10 Seems like a very reasonable change to make!

oed avatar Jan 15 '21 10:01 oed

Possibly related to https://github.com/ceramicnetwork/js-ceramic/issues/9?

stbrody avatar Apr 25 '21 21:04 stbrody