Skip to content

feat: migration from axios to fetch#42

Merged
ErikBjare merged 3 commits intoActivityWatch:masterfrom
saghen:fetch
Jan 31, 2024
Merged

feat: migration from axios to fetch#42
ErikBjare merged 3 commits intoActivityWatch:masterfrom
saghen:fetch

Conversation

@saghen
Copy link
Copy Markdown
Contributor

@saghen saghen commented Jun 1, 2023

As part of my work on ActivityWatch/aw-watcher-web#103, a need to switch from Axios (based on XMLHTTPRequest) to native fetch arose due to the removal of XMLHTTPRequest in Service Workers. These are a requirement for Manifest V3 with Manifest V2 being removed from Chrome soon (see).

Notably, Node.JS gained support for fetch by default in v18 with v16 introducing it via the --experimental-fetch flag. According to the release schedule found here, v16 has been moved to maintenance and will reach end of life on September 11th. Unfortunately, this means that this PR would break support for a maintenance release of Node in the meantime. Users of v16 could either enable support for fetch or use one of the many polyfills.

This PR also removes the timeout option which, if implemented, would involve using a Promise.race and AbortController although I'd be curious if this option is in use. I'm willing to implement it if desired!

@saghen
Copy link
Copy Markdown
Contributor Author

saghen commented Jun 29, 2023

Friendly ping in case this fell under the radar, but no rush! @ErikBjare

Copy link
Copy Markdown
Member

@ErikBjare ErikBjare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I completely missed this, sorry!

Looks good, but a few comments and an issue.

Comment thread src/aw-client.ts
Comment thread src/aw-client.ts Outdated
Comment thread tsconfig.json Outdated
@saghen
Copy link
Copy Markdown
Contributor Author

saghen commented Jan 30, 2024

Changes made based off your comments. I haven't had the chance to test it manually but all tests are passing

@ErikBjare
Copy link
Copy Markdown
Member

Haven't tested myself, but looks good!

Thank you so much for this ❤️

@ErikBjare
Copy link
Copy Markdown
Member

ErikBjare commented Jan 31, 2024

I assume the failing tests is just due to an old node-version in CI. Bumping to 18 and hoping it passes.

Edit: It did 🎉

@ErikBjare ErikBjare merged commit d4ff648 into ActivityWatch:master Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants