Closed
Description
Is there an existing issue for this?
- I have checked for existing issues https://.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/google-cloud-serverless
SDK Version
9.30.0
Framework Version
@sentry/[email protected]
Link to Sentry event
No response
Reproduction Example/SDK Setup
import * as Sentry from "@sentry/google-cloud-serverless";
import { type CloudEvent } from "@google-cloud/functions-framework";
Sentry.wrapCloudEventFunction(async (cloudevent: CloudEvent<any>) => {});
Steps to Reproduce
- Install
@google-cloud/[email protected]
,[email protected]
and@sentry/[email protected]
- Paste repro script
- Run
tsc --noEmit
, strict mode enabled
Worth noting here is that [email protected]
installs "cloudevents": "^8.0.2"
Expected Result
No typechecking errors
Actual Result
> tsc --noEmit
index.ts:30:31 - error TS2345: Argument of type '(cloudevent: CloudEvent<any>) => Promise<void>' is not assignable to parameter of type 'CloudEventFunction | CloudEventFunctionWithCallback'.
Type '(cloudevent: CloudEvent<any>) => Promise<void>' is not assignable to type 'CloudEventFunction'.
Types of parameters 'cloudevent' and 'cloudevent' are incompatible.
Type 'CloudEventsContext' is not assignable to type 'CloudEventV1<any>'.
Types of property 'id' are incompatible.
Type 'string | undefined' is not assignable to type 'string'.
Type 'undefined' is not assignable to type 'string'.
30 Sentry.wrapCloudEventFunction(async (cloudevent: CloudEvent<any>) => {});
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To rephrase the error message; problem is that attributes of the CloudEventsContext
interface from Sentry are not matching with the CloudEvent
interface from Google's functions framework package, where CloudEvent
is reexported from cloudevents.
CloudEventsContext
from Sentry:
vs. CloudEvent
from functions framework (via cloudevents
) (ref: https://.com/cloudevents/sdk-javascript/blob/c07afa9b774deefa137a960d2d11adee0bf3674a/src/event/interfaces.ts#L10-L31):
export interface CloudEventV1<T> extends CloudEventV1Attributes<T> {
// REQUIRED Attributes
/**
* [REQUIRED] Identifies the event. Producers MUST ensure that `source` + `id`
* is unique for each distinct event. If a duplicate event is re-sent (e.g. due
* to a network error) it MAY have the same `id`. Consumers MAY assume that
* Events with identical `source` and `id` are duplicates.
* @required Non-empty string. Unique within producer.
* @example An event counter maintained by the producer
* @example A UUID
*/
id: string;
/**
* [REQUIRED] The version of the CloudEvents specification which the event
* uses. This enables the interpretation of the context. Compliant event
* producers MUST use a value of `1.0` when referring to this version of the
* specification.
* @required MUST be a non-empty string.
*/
specversion: string;
}