Skip to content

Commit

Permalink
fix timeout logic
Browse files Browse the repository at this point in the history
  • Loading branch information
zikaari committed Nov 2, 2023
1 parent 1a96986 commit c2c8e8c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/browser/src/plugins/remote-loader/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,14 @@ export class ActionDestination implements DestinationPlugin {
`action_plugin_name:${this.action.name}`,
])

const ret = await pTimeout(
this.action.load(ctx, analytics),
this.type === 'destination' ? this.destinationTimeout : Infinity
)
const loadP = this.action.load(ctx, analytics)

const ret =
this.type === 'destination'
? pTimeout(loadP, this.destinationTimeout)
: loadP

this.loadPromise.resolve(ret)
this.loadPromise.resolve(await ret)
return ret
} catch (error) {
ctx.stats.increment('analytics_js.action_plugin.invoke.error', 1, [
Expand Down

0 comments on commit c2c8e8c

Please sign in to comment.