From 2c0181d097c7ab2b72624501aeee1447ad1a8da6 Mon Sep 17 00:00:00 2001 From: Henry Heino <46334387+personalizedrefrigerator@users.noreply.github.com> Date: Tue, 14 Nov 2023 10:47:52 -0800 Subject: [PATCH] Desktop, Cli: Fixes #8788: Work around WebDAV sync issues over ipv6 (#9286) --- packages/lib/BaseApplication.ts | 8 ++++++++ packages/lib/utils/processStartFlags.ts | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/packages/lib/BaseApplication.ts b/packages/lib/BaseApplication.ts index 007f646707..95b2988208 100644 --- a/packages/lib/BaseApplication.ts +++ b/packages/lib/BaseApplication.ts @@ -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'); @@ -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, diff --git a/packages/lib/utils/processStartFlags.ts b/packages/lib/utils/processStartFlags.ts index bfd0f28c28..d425b04d4c 100644 --- a/packages/lib/utils/processStartFlags.ts +++ b/packages/lib/utils/processStartFlags.ts @@ -11,6 +11,7 @@ export interface MatchedStartFlags { isSafeMode?: boolean; showStackTraces?: boolean; logLevel?: LogLevel; + allowOverridingDnsResultOrder?: boolean; devPlugins?: string[]; } @@ -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); @@ -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 {