Skip to content

Commit 3be5ab7

Browse files
authored
Bunch of small stuff (#891)
* Fix double import of long in generated proto TS files * Fix bundler with default workflow interceptors * Label grpc-retry API as experimental * Upgrade core, add support for OTEL metric temporality * Limit eager activity requests to 3 * Make the failure-converter code symmetric * Fix tests
1 parent e42fdb0 commit 3be5ab7

File tree

12 files changed

+192
-237
lines changed

12 files changed

+192
-237
lines changed

packages/client/src/grpc-retry.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { InterceptingCall, Interceptor, ListenerBuilder, RequesterBuilder, StatusObject } from '@grpc/grpc-js';
22
import * as grpc from '@grpc/grpc-js';
33

4+
/**
5+
* @experimental
6+
*/
47
export interface GrpcRetryOptions {
58
/**
69
* A function which accepts the current retry attempt (starts at 1) and returns the millisecond
@@ -16,6 +19,8 @@ export interface GrpcRetryOptions {
1619

1720
/**
1821
* Options for the backoff formula: `factor ^ attempt * initialIntervalMs(status) * jitter(maxJitter)`
22+
*
23+
* @experimental
1924
*/
2025
export interface BackoffOptions {
2126
/**
@@ -74,6 +79,8 @@ function withDefaultBackoffOptions({
7479

7580
/**
7681
* Generates the default retry behavior based on given backoff options
82+
*
83+
* @experimental
7784
*/
7885
export function defaultGrpcRetryOptions(options: Partial<BackoffOptions> = {}): GrpcRetryOptions {
7986
const { maxAttempts, factor, maxJitter, initialIntervalMs, maxIntervalMs } = withDefaultBackoffOptions(options);
@@ -125,6 +132,8 @@ function defaultInitialIntervalMs({ code }: StatusObject) {
125132
* Returns a GRPC interceptor that will perform automatic retries for some types of failed calls
126133
*
127134
* @param retryOptions Options for the retry interceptor
135+
*
136+
* @experimental
128137
*/
129138
export function makeGrpcRetryInterceptor(retryOptions: GrpcRetryOptions): Interceptor {
130139
return (options, nextCall) => {

packages/common/src/converter/failure-converter.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,24 +190,26 @@ export class DefaultFailureConverter implements FailureConverter {
190190
}
191191

192192
failureToError(failure: ProtoFailure): TemporalFailure {
193-
const err = this.failureToErrorInner(failure);
194-
err.stack = failure.stackTrace ?? '';
195-
err.failure = failure;
196193
if (failure.encodedAttributes) {
197194
const attrs = this.options.payloadConverter.fromPayload<DefaultEncodedFailureAttributes>(
198195
failure.encodedAttributes
199196
);
200197
// Don't apply encodedAttributes unless they conform to an expected schema
201198
if (typeof attrs === 'object' && attrs !== null) {
202199
const { message, stack_trace } = attrs;
200+
// Avoid mutating the argument
201+
failure = { ...failure };
203202
if (typeof message === 'string') {
204-
err.message = message;
203+
failure.message = message;
205204
}
206205
if (typeof stack_trace === 'string') {
207-
err.stack = stack_trace;
206+
failure.stackTrace = stack_trace;
208207
}
209208
}
210209
}
210+
const err = this.failureToErrorInner(failure);
211+
err.stack = failure.stackTrace ?? '';
212+
err.failure = failure;
211213
return err;
212214
}
213215

0 commit comments

Comments
 (0)