Skip to content

fix: retry compilation if grpc client needs to be reinitialized #2548

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 21, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: use Status enum for status code in ServiceError type guards
This change resolves the issue where the intersection of `ServiceError` error codes of type `number` resulted in the `never` type due to conflict between number and `State` enum if `StatusObject`
  • Loading branch information
giacomocusinato committed Oct 30, 2024
commit d3306e0577bbd59828c24392efe00d0f1f042a48
5 changes: 4 additions & 1 deletion arduino-ide-extension/src/node/service-error.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Metadata, StatusObject } from '@grpc/grpc-js';
import { Status } from './cli-protocol/google/rpc/status_pb';
import { stringToUint8Array } from '../common/utils';
import { Status as StatusCode } from '@grpc/grpc-js/build/src/constants';
import { ProgrammerIsRequiredForUploadError } from './cli-protocol/cc/arduino/cli/commands/v1/upload_pb';

type ProtoError = typeof ProgrammerIsRequiredForUploadError;
Expand All @@ -14,7 +15,9 @@ const protoErrorsMap = new Map<string, ProtoError>([

export type ServiceError = StatusObject & Error;
export namespace ServiceError {
export function isCancel(arg: unknown): arg is ServiceError & { code: 1 } {
export function isCancel(
arg: unknown
): arg is ServiceError & { code: StatusCode.CANCELLED } {
return is(arg) && arg.code === 1; // https://grpc.github.io/grpc/core/md_doc_statuscodes.html
}

Expand Down