feat: add AbortController/AbortSignal support for request cancellation#150
Closed
feat: add AbortController/AbortSignal support for request cancellation#150
Conversation
Co-authored-by: DarinRowe <5706314+DarinRowe@users.noreply.github.com> Agent-Logs-Url: https://github.com/DarinRowe/googletrans/sessions/3974fdb3-f603-4267-8559-f7f186120003
Copilot
AI
changed the title
[WIP] Add ability to abort or cancel request in googletrans
feat: add AbortController/AbortSignal support for request cancellation
Mar 26, 2026
There was a problem hiding this comment.
Pull request overview
Adds AbortController/AbortSignal-based cancellation support to in-flight translation requests by threading an optional abort signal through the public options and into the underlying axios request.
Changes:
- Extend
Optionswithsignal?: AbortSignal. - Forward
signalinto the axios request config intranslate(). - Add Jest coverage for pre-aborted, non-aborted, and aborted requests.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/googletrans.ts |
Extends the translation options and passes the abort signal through to axios for request cancellation. |
src/__tests__/test.ts |
Adds new tests intended to verify AbortController/AbortSignal behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Owner
|
Closing in favor of #151, which now contains the reviewed AbortController support plus stronger deterministic test coverage. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No way to cancel an in-flight translation request — once initiated, it runs to completion or timeout.
Changes
Optionsinterface — addssignal?: AbortSignalfieldtranslate()— forwardssignalto the axios request config (axios ≥1.x supportsAbortSignalnatively)Usage
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
registry.npmmirror.com/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install(dns block)translate.google.com/opt/hostedtoolcache/node/24.14.0/x64/bin/node /opt/hostedtoolcache/node/24.14.0/x64/bin/node /home/REDACTED/work/googletrans/googletrans/node_modules/jest-worker/build/workers/processChild.js(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node node_modules/jest/bin/jest.js --config jestconfig.json --testNamePattern=AbortController --runInBand(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.