Async import of the appStore packages#10
Conversation
Codoki PR ReviewSummary: Guard async app imports, prevent crashes Issues (Critical & High only)
Showing top 5 issues. Critical: 0, High: 5. See inline suggestions for more. Key Feedback (click to expand)
Confidence: 2/5 — Not ready to merge (5 high · status: Requires changes) Sequence DiagramsequenceDiagram
participant Caller
participant handlePayment
participant appStore
participant PaymentService
participant paymentInstance
Caller->>handlePayment: handlePayment(evt, selectedEventType, creds, booking)
handlePayment->>appStore: [dirName]
alt app not implemented
handlePayment-->>Caller: return null
else app implemented
handlePayment->>PaymentService: new PaymentService(creds)
PaymentService-->>handlePayment: instance
handlePayment->>paymentInstance: create({ amount, currency }, booking.id)
paymentInstance-->>handlePayment: paymentData
alt paymentData falsy
handlePayment-->>Caller: throw Error("Payment data is null")
else paymentData truthy
handlePayment->>paymentInstance: afterPayment(evt, booking, paymentData)
paymentInstance-->>handlePayment: void
handlePayment-->>Caller: paymentData
end
end
React with 👍 or 👎 if you found this review useful. |
| ); | ||
| try { | ||
| bookingRefsFiltered.forEach((bookingRef) => { | ||
| bookingRefsFiltered.forEach(async (bookingRef) => { |
There was a problem hiding this comment.
| bookingRefsFiltered.forEach(async (bookingRef) => { | |
| ```suggestion | |
| const tasks = bookingRefsFiltered.map(async (bookingRef) => { | |
| if (!bookingRef.uid) return; | |
| if (bookingRef.type.endsWith("_calendar")) { | |
| const calendar = await getCalendar(credentialsMap.get(bookingRef.type)); | |
| return calendar?.deleteEvent(bookingRef.uid, builder.calendarEvent); | |
| } | |
| if (bookingRef.type.endsWith("_video")) { | |
| return deleteMeeting(credentialsMap.get(bookingRef.type), bookingRef.uid); | |
| } | |
| }); | |
| await Promise.all(tasks); |
| ); | ||
| try { | ||
| bookingRefsFiltered.forEach((bookingRef) => { | ||
| bookingRefsFiltered.forEach(async (bookingRef) => { |
There was a problem hiding this comment.
| bookingRefsFiltered.forEach(async (bookingRef) => { | |
| ```suggestion | |
| const tasks = bookingRefsFiltered.map(async (bookingRef) => { | |
| if (!bookingRef.uid) return; | |
| if (bookingRef.type.endsWith("_calendar")) { | |
| const calendar = await getCalendar(credentialsMap.get(bookingRef.type)); | |
| return calendar?.deleteEvent( | |
| bookingRef.uid, | |
| builder.calendarEvent | |
| ); | |
| } | |
| if (bookingRef.type.endsWith("_video")) { | |
| return deleteMeeting(credentialsMap.get(bookingRef.type), bookingRef.uid); | |
| } | |
| }); | |
| await Promise.all(tasks); |
| } | ||
| ): Promise<boolean> => { | ||
| const paymentApp = appStore[paymentAppCredentials?.app?.dirName as keyof typeof appStore]; | ||
| const paymentApp = await appStore[paymentAppCredentials?.app?.dirName as keyof typeof appStore]; |
There was a problem hiding this comment.
| const paymentApp = await appStore[paymentAppCredentials?.app?.dirName as keyof typeof appStore]; | |
| ```suggestion | |
| let paymentApp; | |
| try { | |
| paymentApp = await appStore[paymentAppCredentials?.app?.dirName as keyof typeof appStore]; | |
| } catch (err) { | |
| console.warn(`Failed to load payment app: ${paymentAppCredentials?.app?.dirName}`, err); | |
| return false; | |
| } |
| } | ||
| ) => { | ||
| const paymentApp = appStore[paymentAppCredentials?.app?.dirName as keyof typeof appStore]; | ||
| const paymentApp = await appStore[paymentAppCredentials?.app?.dirName as keyof typeof appStore]; |
There was a problem hiding this comment.
| const paymentApp = await appStore[paymentAppCredentials?.app?.dirName as keyof typeof appStore]; | |
| ```suggestion | |
| let paymentApp; | |
| try { | |
| paymentApp = await appStore[paymentAppCredentials?.app?.dirName as keyof typeof appStore]; | |
| } catch (err) { | |
| console.warn(`Failed to load payment app: ${paymentAppCredentials?.app?.dirName}`, err); | |
| return null; | |
| } |
No description provided.