Skip to content

Commit

Permalink
derive-bites: use callback only where rt is used
Browse files Browse the repository at this point in the history
  • Loading branch information
olegbespalov committed Apr 12, 2024
1 parent cb23f63 commit 411de40
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions webcrypto/subtle_crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ func (sc *SubtleCrypto) DeriveBits(algorithm goja.Value, baseKey goja.Value, len
return promise
}

callback(func() error {
go func() {
result, err := func() ([]byte, error) {
deriver, err := newBitsDeriver(algName)
if err != nil {
Expand All @@ -663,12 +663,14 @@ func (sc *SubtleCrypto) DeriveBits(algorithm goja.Value, baseKey goja.Value, len
}()
if err != nil {
reject(err)
return nil
return
}

resolve(rt.NewArrayBuffer(result))
return nil
})
callback(func() error {
resolve(rt.NewArrayBuffer(result))
return nil
})
}()

return promise
}
Expand Down

0 comments on commit 411de40

Please sign in to comment.