Skip to content
This repository was archived by the owner on Jun 20, 2022. It is now read-only.

Commit 1d4c6f2

Browse files
authored
fix: file download dom exception (#863)
1 parent c065efe commit 1d4c6f2

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

app/enableExperimentalWebFeatures.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { app } from 'electron'
2+
3+
/**
4+
* @FIXME
5+
* Due to a bug in Electron (https://github.com/electron/electron/issues/28422),
6+
* downloading a file using the File System Access API does not work, causing an exception:
7+
* "Uncaught DOMException: The request is not allowed by the user agent or the platform in the current context."
8+
*
9+
* The following workaround fixes the issue by enabling experimental web platform features
10+
* which makes the file system access permission always be true.
11+
*
12+
* Since this workaround involves enabling experimental features, it could lead
13+
* to other issues. This should be removed as soon as the upstream bug is fixed.
14+
*/
15+
export const enableExperimentalFeaturesForFileAccessFix = () =>
16+
app.commandLine.appendSwitch('enable-experimental-web-platform-features')

app/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import { setupTesting } from './javascripts/Main/Utils/Testing'
1010
import { CommandLineArgs } from './javascripts/Shared/CommandLineArgs'
1111
import { Store, StoreKeys } from './javascripts/Main/Store'
1212
import { Paths } from './javascripts/Main/Types/Paths'
13+
import { enableExperimentalFeaturesForFileAccessFix } from './enableExperimentalWebFeatures'
14+
15+
enableExperimentalFeaturesForFileAccessFix()
1316

1417
require('@electron/remote/main').initialize()
1518

0 commit comments

Comments
 (0)