Skip to content

fix: 🐛 add error handling for docker service startup failures#1880

Merged
chronark merged 10 commits intounkeyed:mainfrom
DeepaPrasanna:fix/show-errors-in-pnpm-local
Jul 22, 2024
Merged

fix: 🐛 add error handling for docker service startup failures#1880
chronark merged 10 commits intounkeyed:mainfrom
DeepaPrasanna:fix/show-errors-in-pnpm-local

Conversation

@DeepaPrasanna
Copy link
Contributor

What does this PR do?

Fixes #1877

Updated the code to handle errors when starting docker services. If the service startup fails, an error is thrown with a descriptive message indicating which service encountered the issue.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Chore (refactoring code, technical debt, workflow improvements)
  • Enhancement (small improvements)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How should this be tested?

  • Run pnpm local without running docker.

Checklist

Required

  • Filled out the "How to test" section in this PR
  • Read Contributing Guide
  • Self-reviewed my own code
  • Commented on my code in hard-to-understand areas
  • Ran pnpm build
  • Ran pnpm fmt
  • Checked for warnings, there are none
  • Removed all console.logs
  • Merged the latest changes from main onto my branch with git pull origin main
  • My changes don't cause any responsiveness issues

Appreciated

  • If a UI change was made: Added a screen recording or screenshots to this PR
  • Updated the Unkey Docs if changes were necessary

@changeset-bot
Copy link

changeset-bot bot commented Jul 9, 2024

⚠️ No Changeset found

Latest commit: 81b610f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Jul 9, 2024

@DeepaPrasanna is attempting to deploy a commit to the Unkey Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 9, 2024

Thank you for following the naming conventions for pull request titles! 🙏

@chronark
Copy link
Collaborator

chronark commented Jul 9, 2024

This is better than what we currently have, but it would be nice if we can return the original error, so the user actually has something to work with

@DeepaPrasanna
Copy link
Contributor Author

The error was only a code with value 1, so that's why I thought it will be unclear to return that value.

@chronark
Copy link
Collaborator

chronark commented Jul 9, 2024

docker definitely returns more descriptive errors than that

@DeepaPrasanna
Copy link
Contributor Author

Hmm, maybe I missed. I will have a look at it again.

@DeepaPrasanna
Copy link
Contributor Author

DeepaPrasanna commented Jul 10, 2024

Is this okay? I am now thinking of throwing the original error

Untitled

@chronark
Copy link
Collaborator

that doesn't help a developer. we need to return the actual error from the command that ran, not the error from the node:child_process

@DeepaPrasanna
Copy link
Contributor Author

did u meant the stderr from the command itself?

Copy link
Collaborator

yes

@DeepaPrasanna
Copy link
Contributor Author

DeepaPrasanna commented Jul 10, 2024

In that case, It was empty. I will attach a screenshot.
image

That why I went with error

Edit: It seems docker prints errors to stdout instead of stderr. When docker successfully runs, these are the logs
image

@DeepaPrasanna
Copy link
Contributor Author

shall i return stdout along with error ?

@chronark
Copy link
Collaborator

yeah that makes sense I think

@DeepaPrasanna
Copy link
Contributor Author

Is this okay?

Screenshot 2024-07-18 223255

Copy link
Collaborator

👍

@DeepaPrasanna
Copy link
Contributor Author

I pushed the required changes.

const p = exec(cmd, opts, (error, stdout) => {
if (error) {
// biome-ignore lint/suspicious/noConsoleLog: logging seems the best option here
console.log(stdout);
Copy link
Collaborator

Choose a reason for hiding this comment

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

it's an error, why don't we use console.error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that should have been used

@chronark chronark merged commit cd419e2 into unkeyed:main Jul 22, 2024
@DeepaPrasanna DeepaPrasanna deleted the fix/show-errors-in-pnpm-local branch July 22, 2024 16:37
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.

pnpm local should show errors

2 participants