ceramicnetwork / js-ceramic

Typescript implementation of the Ceramic protocol
http://ceramic.network
Other
414 stars 127 forks source link

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

Open Schwartz10 opened 3 years ago

Schwartz10 commented 3 years ago

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.

oed commented 3 years ago

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

stbrody commented 3 years ago

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

btme0011 commented 10 months ago

can i work on this issue?

oed commented 10 months ago

@btme0011 This issue is pretty old so not sure if it's still a problem actually. If you can replicate it then feel free!

samuelarogbonlo commented 1 month ago

Are we still allowed to pick up this issue ? @oed