Skip to content

Commit

Permalink
Desktop, Cli: Fixes #8788: Work around WebDAV sync issues over ipv6 (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
personalizedrefrigerator authored Nov 14, 2023
1 parent 06ea12a commit 2c0181d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/lib/BaseApplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import time from './time';
import BaseSyncTarget from './BaseSyncTarget';
const reduxSharedMiddleware = require('./components/shared/reduxSharedMiddleware');
const os = require('os');
import dns = require('dns');
import fs = require('fs-extra');
const EventEmitter = require('events');
const syswidecas = require('./vendor/syswide-cas');
Expand Down Expand Up @@ -171,6 +172,13 @@ export default class BaseApplication {
this.showStackTraces_ = true;
}

// Work around issues with ipv6 resolution -- default to ipv4first.
// (possibly incorrect URL serialization see https://github.com/mswjs/msw/issues/1388#issuecomment-1241180921).
// See also https://github.com/node-fetch/node-fetch/issues/1624#issuecomment-1407717012
if (flags.matched.allowOverridingDnsResultOrder) {
dns.setDefaultResultOrder('ipv4first');
}

return {
matched: flags.matched,
argv: flags.argv,
Expand Down
10 changes: 10 additions & 0 deletions packages/lib/utils/processStartFlags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface MatchedStartFlags {
isSafeMode?: boolean;
showStackTraces?: boolean;
logLevel?: LogLevel;
allowOverridingDnsResultOrder?: boolean;
devPlugins?: string[];
}

Expand Down Expand Up @@ -63,6 +64,14 @@ const processStartFlags = async (argv: string[], setDefaults = true) => {
continue;
}

if (arg.startsWith('--dns-result-order=')) {
matched.allowOverridingDnsResultOrder = false;

// Handled by Electron/NodeJS (and indicates we shouldn't override this ourselves).
argv.splice(0, 1);
continue;
}

if (arg === '--debug') {
// Currently only handled by ElectronAppWrapper (isDebugMode property)
argv.splice(0, 1);
Expand Down Expand Up @@ -168,6 +177,7 @@ const processStartFlags = async (argv: string[], setDefaults = true) => {
if (!matched.logLevel) matched.logLevel = Logger.LEVEL_INFO;
if (!matched.env) matched.env = 'prod';
if (!matched.devPlugins) matched.devPlugins = [];
matched.allowOverridingDnsResultOrder ??= true;
}

return {
Expand Down

0 comments on commit 2c0181d

Please sign in to comment.