-
Notifications
You must be signed in to change notification settings - Fork 41.8k
Pause automatic updates on metered connections #331701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Dmitriy Vasyura (dmitrivMS)
merged 8 commits into
main
from
dev/dmitriv/metered-update-checks
Aug 20, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
84ef5e0
update: respect metered connections
dmitrivMS 3b7c6f1
Fix deferred metered update handling
dmitrivMS 667e737
Merge branch 'main' into dev/dmitriv/metered-update-checks
dmitrivMS 017fbaf
Fix deferred metered update resumption
dmitrivMS fb03e92
Fix metered update ordering races
dmitrivMS 217bf67
Merge branch 'main' into dev/dmitriv/metered-update-checks
dmitrivMS 21b1bc4
Merge branch 'main' into dev/dmitriv/metered-update-checks
dmitrivMS b726f11
chore: create empty commit
dmitrivMS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/vs/platform/meteredConnection/test/electron-browser/meteredConnectionService.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| * Licensed under the MIT License. See License.txt in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| import assert from 'assert'; | ||
| import { CancellationToken } from '../../../../base/common/cancellation.js'; | ||
| import { Event } from '../../../../base/common/event.js'; | ||
| import { IChannel } from '../../../../base/parts/ipc/common/ipc.js'; | ||
| import { mock } from '../../../../base/test/common/mock.js'; | ||
| import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../base/test/common/utils.js'; | ||
| import { TestConfigurationService } from '../../../configuration/test/common/testConfigurationService.js'; | ||
| import { IMainProcessService } from '../../../ipc/common/mainProcessService.js'; | ||
| import { METERED_CONNECTION_CHANNEL, MeteredConnectionCommand } from '../../common/meteredConnectionIpc.js'; | ||
| import { NativeMeteredConnectionService } from '../../electron-browser/meteredConnectionService.js'; | ||
|
|
||
| class TestChannel implements IChannel { | ||
| readonly calls: { command: string; argument: unknown }[] = []; | ||
|
|
||
| call<T>(command: string, arg?: unknown, _cancellationToken?: CancellationToken): Promise<T> { | ||
| this.calls.push({ command, argument: arg }); | ||
| return Promise.resolve(undefined as T); | ||
| } | ||
|
|
||
| listen<T>(_event: string, _arg?: unknown): Event<T> { | ||
| return Event.None; | ||
| } | ||
| } | ||
|
|
||
| suite('NativeMeteredConnectionService', () => { | ||
| const store = ensureNoDisposablesAreLeakedInTestSuite(); | ||
|
|
||
| test('reports the initial browser connection state to the main process', () => { | ||
| const channel = new TestChannel(); | ||
| const mainProcessService = new class extends mock<IMainProcessService>() { | ||
| override getChannel(channelName: string): IChannel { | ||
| assert.strictEqual(channelName, METERED_CONNECTION_CHANNEL); | ||
| return channel; | ||
| } | ||
| }; | ||
| const configurationService = new TestConfigurationService(); | ||
| store.add(configurationService.onDidChangeConfigurationEmitter); | ||
|
|
||
| store.add(new NativeMeteredConnectionService(() => true, configurationService, mainProcessService)); | ||
|
|
||
| assert.deepStrictEqual(channel.calls, [{ | ||
| command: MeteredConnectionCommand.SetIsBrowserConnectionMetered, | ||
| argument: true, | ||
| }]); | ||
| }); | ||
| }); |
36 changes: 36 additions & 0 deletions
36
src/vs/platform/meteredConnection/test/electron-main/meteredConnectionMainService.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| * Licensed under the MIT License. See License.txt in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| import assert from 'assert'; | ||
| import { timeout } from '../../../../base/common/async.js'; | ||
| import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../base/test/common/utils.js'; | ||
| import { TestConfigurationService } from '../../../configuration/test/common/testConfigurationService.js'; | ||
| import { MeteredConnectionMainService } from '../../electron-main/meteredConnectionMainService.js'; | ||
|
|
||
| suite('MeteredConnectionMainService', () => { | ||
| const store = ensureNoDisposablesAreLeakedInTestSuite(); | ||
|
|
||
| test('initialization waits for the initial browser connection state', async () => { | ||
| const configurationService = new TestConfigurationService(); | ||
| store.add(configurationService.onDidChangeConfigurationEmitter); | ||
| const service = store.add(new MeteredConnectionMainService(configurationService)); | ||
| let initialized = false; | ||
| void service.whenConnectionStateInitialized.then(() => initialized = true); | ||
|
|
||
| await timeout(0); | ||
| assert.strictEqual(initialized, false); | ||
|
|
||
| service.setIsBrowserConnectionMetered(true); | ||
| await service.whenConnectionStateInitialized; | ||
|
|
||
| assert.deepStrictEqual({ | ||
| initialized, | ||
| isConnectionMetered: service.isConnectionMetered, | ||
| }, { | ||
| initialized: true, | ||
| isConnectionMetered: true, | ||
| }); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.