@@ -18,9 +18,7 @@ const initPublicEmailWorker = () => {
1818 // Initialize Worker with Rate Limiting (10 per second to respect Resend limits)
1919 worker = new Worker ( 'public-email-queue' , async ( job ) => {
2020 const { projectId, payload, usingByok, consumedQuotaKey } = job . data ;
21-
22- try {
23-
21+
2422 let clientKey = process . env . RESEND_API_KEY_2 || process . env . RESEND_API_KEY ;
2523 let fromAddress = process . env . EMAIL_FROM || "urBackend <urbackend@apps.bitbros.in>" ;
2624
@@ -31,8 +29,8 @@ const initPublicEmailWorker = () => {
3129 const decrypted = decrypt ( project . resendApiKey ) ;
3230 if ( typeof decrypted === 'string' && decrypted . trim ( ) . length > 0 ) {
3331 clientKey = decrypted . trim ( ) ;
34- fromAddress = project . resendFromEmail && project . resendFromEmail . trim ( )
35- ? project . resendFromEmail . trim ( )
32+ fromAddress = project . resendFromEmail && project . resendFromEmail . trim ( )
33+ ? project . resendFromEmail . trim ( )
3634 : "onboarding@resend.dev" ;
3735 }
3836 }
@@ -65,18 +63,15 @@ const initPublicEmailWorker = () => {
6563 const maskedTo = toList . map ( redact ) . join ( ', ' ) ;
6664
6765 console . log ( `[Queue] Processing public email to: ${ maskedTo } ` ) ;
68-
66+
6967 const { data, error } = await resend . emails . send ( finalPayload ) ;
70-
68+
7169 if ( error ) {
7270 console . error ( `[Queue] Failed to send public email to ${ maskedTo } :` , error ) ;
7371 throw new Error ( error . message || "Failed to send email" ) ;
7472 }
75-
73+
7674 return { data } ;
77- } catch ( err ) {
78- throw err ;
79- }
8075 } , {
8176 connection,
8277 limiter : {
@@ -94,8 +89,7 @@ const initPublicEmailWorker = () => {
9489 if ( job && job . data && job . data . consumedQuotaKey ) {
9590 const maxAttempts = job . opts ?. attempts || 1 ;
9691 if ( job . attemptsMade >= maxAttempts ) {
97- const luaScript = DECR_IF_EXISTS_SCRIPT ;
98- await connection . eval ( luaScript , 1 , job . data . consumedQuotaKey ) . catch ( ( ) => { } ) ;
92+ await connection . eval ( DECR_IF_EXISTS_SCRIPT , 1 , job . data . consumedQuotaKey ) . catch ( ( ) => { } ) ;
9993 }
10094 }
10195 } ) ;
0 commit comments