@@ -140,12 +140,30 @@ export default class SentryEventWorker extends Worker {
140140
141141 /**
142142 * Safely check if SDK name exists and is in the list
143+ * SDK name can be either a simple name like "react" or a full name like "sentry.javascript.react"
143144 */
144145 const sdkName = payloadHasSDK && itemPayload . sdk && typeof itemPayload . sdk === 'object' && 'name' in itemPayload . sdk
145146 ? itemPayload . sdk . name
146147 : undefined ;
147148
148- const isJsSDK = sdkName !== undefined && sentryJsSDK . includes ( sdkName ) ;
149+ /**
150+ * Check if SDK is a JavaScript-related SDK
151+ * Supports both simple names (e.g., "react") and full names (e.g., "sentry.javascript.react")
152+ */
153+ const isJsSDK = sdkName !== undefined && typeof sdkName === 'string' && (
154+ /**
155+ * Exact match for simple SDK names (e.g., "react", "browser")
156+ */
157+ sentryJsSDK . includes ( sdkName ) ||
158+ /**
159+ * Check if SDK name contains one of the JS SDK names
160+ * Examples:
161+ * - "sentry.javascript.react" matches "react"
162+ * - "sentry.javascript.browser" matches "browser"
163+ * - "@sentry/react" matches "react"
164+ */
165+ sentryJsSDK . some ( ( jsSDK ) => sdkName . includes ( jsSDK ) )
166+ ) ;
149167
150168 const hawkEvent = this . transformToHawkFormat ( envelopeHeaders as EventEnvelope [ 0 ] , item as EventItem , projectId , isJsSDK ) ;
151169
@@ -158,7 +176,6 @@ export default class SentryEventWorker extends Worker {
158176 if ( ! taskSent ) {
159177 /**
160178 * If addTask returns false, the message was not queued (queue full or channel closed)
161- * This is a critical error that should be logged and thrown
162179 */
163180 const error = new Error ( `Failed to queue event to ${ workerName } worker. Queue may be full or channel closed.` ) ;
164181 this . logger . error ( error . message ) ;
@@ -167,7 +184,6 @@ export default class SentryEventWorker extends Worker {
167184 throw error ;
168185 }
169186
170- this . logger . verbose ( `Successfully queued event to ${ workerName } worker` ) ;
171187 return 'processed' ;
172188 } catch ( error ) {
173189 this . logger . error ( 'Error handling envelope item:' , error ) ;
@@ -198,7 +214,14 @@ export default class SentryEventWorker extends Worker {
198214 * convert sent_at from ISO 8601 to Unix timestamp
199215 */
200216 const msInSecond = 1000 ;
201- const sentAtUnix = Math . floor ( new Date ( sent_at ) . getTime ( ) / msInSecond ) ;
217+ const sentAtDate = new Date ( sent_at ) ;
218+ const sentAtTime = sentAtDate . getTime ( ) ;
219+
220+ if ( isNaN ( sentAtTime ) ) {
221+ throw new Error ( `Invalid sent_at timestamp: ${ sent_at } ` ) ;
222+ }
223+
224+ const sentAtUnix = Math . floor ( sentAtTime / msInSecond ) ;
202225 /* eslint-enable @typescript-eslint/naming-convention */
203226
204227 // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars
@@ -211,9 +234,18 @@ export default class SentryEventWorker extends Worker {
211234 * We need to decode it to JSON
212235 */
213236 if ( eventPayload instanceof Uint8Array ) {
214- const textDecoder = new TextDecoder ( ) ;
237+ try {
238+ const textDecoder = new TextDecoder ( ) ;
239+ const decoded = textDecoder . decode ( eventPayload as Uint8Array ) ;
215240
216- eventPayload = JSON . parse ( textDecoder . decode ( eventPayload as Uint8Array ) ) ;
241+ try {
242+ eventPayload = JSON . parse ( decoded ) ;
243+ } catch ( parseError ) {
244+ throw new Error ( `Failed to parse event payload JSON: ${ parseError instanceof Error ? parseError . message : String ( parseError ) } ` ) ;
245+ }
246+ } catch ( decodeError ) {
247+ throw new Error ( `Failed to decode Uint8Array event payload: ${ decodeError instanceof Error ? decodeError . message : String ( decodeError ) } ` ) ;
248+ }
217249 }
218250
219251 const title = composeTitle ( eventPayload ) ;
0 commit comments