Skip to content

Commit

Permalink
Add try/catch around workers again
Browse files Browse the repository at this point in the history
  • Loading branch information
simolus3 committed Jan 20, 2025
1 parent cb7672b commit 264e02e
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions sqlite3_web/lib/src/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,16 @@ final class DatabaseClient implements WebSqlite {

Future<void> _startDedicated() async {
if (globalContext.has('Worker')) {
final dedicated = Worker(
workerUri.toString().toJS,
WorkerOptions(name: 'sqlite3_worker'),
);
final Worker dedicated;
try {
dedicated = Worker(
workerUri.toString().toJS,
WorkerOptions(name: 'sqlite3_worker'),
);
} on Object {
_missingFeatures.add(MissingBrowserFeature.dedicatedWorkers);
return;
}

final (endpoint, channel) = await createChannel();
ConnectRequest(endpoint: endpoint, requestId: 0).sendToWorker(dedicated);
Expand All @@ -322,7 +328,14 @@ final class DatabaseClient implements WebSqlite {

Future<void> _startShared() async {
if (globalContext.has('SharedWorker')) {
final shared = SharedWorker(workerUri.toString().toJS);
final SharedWorker shared;
try {
shared = SharedWorker(workerUri.toString().toJS);
} on Object {
_missingFeatures.add(MissingBrowserFeature.sharedWorkers);
return;
}

shared.port.start();

final (endpoint, channel) = await createChannel();
Expand Down

0 comments on commit 264e02e

Please sign in to comment.