iOSのSafariでWebKitBlobResource error 1

JavascriptからAPIを叩いて、ファイルをダウンロードしていたところ、iOSSafariから以下のように言われてしまった。

Safari cannot open the page.
The error was: "The operation couldn't be completed. (WebKitBlobResource error 1)".

MacSafariChromeからは問題なくダウンロードできていた。

環境

問題のコード

async function downloadFile(url) {
  const res = await axios({
    method: 'get',
    url: url,
    responseType: 'blob',
  })

  const fileUrl = window.URL.createObjectURL(new Blob([res.data]))
  const filename = 'sample.zip'
  let fileLink = document.createElement('a')
  fileLink.href = fileUrl
  fileLink.setAttribute('download', filename)
  document.body.appendChild(fileLink)
  fileLink.click()

  URL.revokeObjectURL(fileUrl)
  document.body.removeChild(fileLink)
}

対策

解放処理をsetTimeoutする。

setTimeout(() => {
  URL.revokeObjectURL(fileUrl)
  document.body.removeChild(fileLink)
}, 200)

参考

javascript - Blob createObjectURL download not working in Firefox (but works when debugging) - Stack Overflow