Skip to content
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

refactor: switch from Axios for Fetch API #840

Merged
merged 21 commits into from
Jul 14, 2024
Merged

Conversation

gauthier-th
Copy link
Collaborator

Description

This PR switch our codebase from the Axios library to the native Fetch API instead.

Screenshot (if UI-related)

To-Dos

  • Successful build yarn build
  • Translation keys yarn i18n:extract
  • Database migration (if required)

Issues Fixed or Closed

  • Fixes #XXXX

@gauthier-th gauthier-th marked this pull request as ready for review June 28, 2024 15:12
@@ -24,6 +24,7 @@ const UserWarnings: React.FC<UserWarningsProps> = ({ onClick }) => {
let res = null;

//check if a user has warnings
console.log(user);
Copy link
Owner

Choose a reason for hiding this comment

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

Remove the console log

Copy link

This pull request has merge conflicts. Please resolve the conflicts so the PR can be successfully reviewed and merged.

@github-actions github-actions bot added the merge conflict Cannot merge due to merge conflicts label Jun 29, 2024
@github-actions github-actions bot removed the merge conflict Cannot merge due to merge conflicts label Jun 30, 2024
@Gauvino
Copy link
Contributor

Gauvino commented Jul 4, 2024

Thank for the PR and after some test this is all the bugs I have encounter:

First: in movies and series when changing of sort type it break the image render
chrome_r8YWmAOJt2
Second: when adding a filter half of the show or render
chrome_08B0RlEUQO
Third: can't comment on issue
CCUmuYQfZf
Fourth: can't update a user in every section, only permissions one seem's to work, and for editing our account only notifications don't work
chrome_RZkHtQrdBc
Fifth: when clicking on a movie, and clicking on a similar title it render with the image of the previous movie, also similar title movie don't render at all
chrome_Hrw1yTrlBJ
uLTVTPRNXS

@Fallenbagel
Copy link
Owner

@Gauvino your fourth bug, is not a bug. You can't save because of our current email validation. That user needs a proper email in their email field then you can save

@Fallenbagel Fallenbagel added the help wanted Extra attention is needed label Jul 9, 2024
@Fallenbagel
Copy link
Owner

We need help on this PR.

Running into an issue where every now and then on not that slow but somewhat slow Internet like 30mbps etc. This might be related to the bugs that @Gauvino posted on their comment.

Fetch request keeps timing out.

TypeError: fetch failed
    at node:internal/deps/undici/undici:12618:11
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async JellyfinAPI.get (/home/fallenbagel/code/jellyseerr/server/api/externalapi.ts:76:24)
    at async JellyfinAPI.getItemData (/home/fallenbagel/code/jellyseerr/server/api/jellyfin.ts:349:28)
    at async JellyfinScanner.processMovie (/home/fallenbagel/code/jellyseerr/server/lib/scanners/jellyfin/index.ts:63:24)
    at async /home/fallenbagel/code/jellyseerr/server/lib/scanners/jellyfin/index.ts:514:11
    at async Promise.all (index 18)
    at async JellyfinScanner.processItems (/home/fallenbagel/code/jellyseerr/server/lib/scanners/jellyfin/index.ts:511:5)
    at async JellyfinScanner.loop (/home/fallenbagel/code/jellyseerr/server/lib/scanners/jellyfin/index.ts:543:7)
    at async JellyfinScanner.run (/home/fallenbagel/code/jellyseerr/server/lib/scanners/jellyfin/index.ts:657:11) {
  cause: ConnectTimeoutError: Connect Timeout Error
      at onConnectTimeout (node:internal/deps/undici/undici:7760:28)
      at node:internal/deps/undici/undici:7716:50
      at Immediate._onImmediate (node:internal/deps/undici/undici:7748:13)
      at processImmediate (node:internal/timers:478:21) {
    code: 'UND_ERR_CONNECT_TIMEOUT'
  }
}
Request took 10004ms

So we need input from someone who has any experience in solving this issue

@gauthier-th gauthier-th marked this pull request as draft July 9, 2024 14:17
@M0NsTeRRR
Copy link

We need help on this PR.

Running into an issue where every now and then on not that slow but somewhat slow Internet like 30mbps etc. This might be related to the bugs that @Gauvino posted on their comment.

Fetch request keeps timing out.

TypeError: fetch failed
    at node:internal/deps/undici/undici:12618:11
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async JellyfinAPI.get (/home/fallenbagel/code/jellyseerr/server/api/externalapi.ts:76:24)
    at async JellyfinAPI.getItemData (/home/fallenbagel/code/jellyseerr/server/api/jellyfin.ts:349:28)
    at async JellyfinScanner.processMovie (/home/fallenbagel/code/jellyseerr/server/lib/scanners/jellyfin/index.ts:63:24)
    at async /home/fallenbagel/code/jellyseerr/server/lib/scanners/jellyfin/index.ts:514:11
    at async Promise.all (index 18)
    at async JellyfinScanner.processItems (/home/fallenbagel/code/jellyseerr/server/lib/scanners/jellyfin/index.ts:511:5)
    at async JellyfinScanner.loop (/home/fallenbagel/code/jellyseerr/server/lib/scanners/jellyfin/index.ts:543:7)
    at async JellyfinScanner.run (/home/fallenbagel/code/jellyseerr/server/lib/scanners/jellyfin/index.ts:657:11) {
  cause: ConnectTimeoutError: Connect Timeout Error
      at onConnectTimeout (node:internal/deps/undici/undici:7760:28)
      at node:internal/deps/undici/undici:7716:50
      at Immediate._onImmediate (node:internal/deps/undici/undici:7748:13)
      at processImmediate (node:internal/timers:478:21) {
    code: 'UND_ERR_CONNECT_TIMEOUT'
  }
}
Request took 10004ms

So we need input from someone who has any experience in solving this issue

Hello,

https://undici.nodejs.org/#/?id=network-address-family-autoselection
UND_ERR_CONNECT_TIMEOUT is an issue related to IPv6, not a slow connection according to the documentation. Additionally, 30mbps is not a slow connection. A timeout of 10004ms is expected to timeout. To test with a bad connection, open the network tab in your browser and set the speed limitation to 2G (40 kbit/s).

@gauthier-th
Copy link
Collaborator Author

We need help on this PR.

Running into an issue where every now and then on not that slow but somewhat slow Internet like 30mbps etc. This might be related to the bugs that @Gauvino posted on their comment.

Fetch request keeps timing out.

TypeError: fetch failed
    at node:internal/deps/undici/undici:12618:11
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async JellyfinAPI.get (/home/fallenbagel/code/jellyseerr/server/api/externalapi.ts:76:24)
    at async JellyfinAPI.getItemData (/home/fallenbagel/code/jellyseerr/server/api/jellyfin.ts:349:28)
    at async JellyfinScanner.processMovie (/home/fallenbagel/code/jellyseerr/server/lib/scanners/jellyfin/index.ts:63:24)
    at async /home/fallenbagel/code/jellyseerr/server/lib/scanners/jellyfin/index.ts:514:11
    at async Promise.all (index 18)
    at async JellyfinScanner.processItems (/home/fallenbagel/code/jellyseerr/server/lib/scanners/jellyfin/index.ts:511:5)
    at async JellyfinScanner.loop (/home/fallenbagel/code/jellyseerr/server/lib/scanners/jellyfin/index.ts:543:7)
    at async JellyfinScanner.run (/home/fallenbagel/code/jellyseerr/server/lib/scanners/jellyfin/index.ts:657:11) {
  cause: ConnectTimeoutError: Connect Timeout Error
      at onConnectTimeout (node:internal/deps/undici/undici:7760:28)
      at node:internal/deps/undici/undici:7716:50
      at Immediate._onImmediate (node:internal/deps/undici/undici:7748:13)
      at processImmediate (node:internal/timers:478:21) {
    code: 'UND_ERR_CONNECT_TIMEOUT'
  }
}
Request took 10004ms

So we need input from someone who has any experience in solving this issue

Hello,

https://undici.nodejs.org/#/?id=network-address-family-autoselection
UND_ERR_CONNECT_TIMEOUT is an issue related to IPv6, not a slow connection according to the documentation. Additionally, 30mbps is not a slow connection. A timeout of 10004ms is expected to timeout. To test with a bad connection, open the network tab in your browser and set the speed limitation to 2G (40 kbit/s).

Thanks for your response.
These issues are happening on the backend of the application, so it's not possible to debug with browser tools.

For IPv6, we tried things like adding --dns-result-order=ipv4first as argument.
I didn't manage to replicate this issue, but @Fallenbagel did so he may have other insights.

We'd be happy to try out other ideas.

@M0NsTeRRR
Copy link

M0NsTeRRR commented Jul 9, 2024

Thanks for your feedback. dns-result-order should not help at all alone, as it only manages the DNS response order (IPv4 first doesn't prevent you from still getting both IPv4 and IPv6 results).

From the documentation if i'm not misleading the default configuration set getdefaultautoselectfamily to true which use first AAAA record first (if returned), first A, second AAAA, second A etc.

To confirm the IPv6 issue I see some possibilities to try (I'm not a Node.js expert, so I might miss some steps.) :

  • Force IPv6 connection with family in the TCP socket.
  • Using NODE_OPTIONS="--dns-result-order=ipv4first --no-network-family-autoselection" which should return IPv4 first and use the first returned record.
  • Disable IPv6 on the host to test
  • Fix IPv6 configuration on the host

Concerning the root cause, I suspect that Node.js detects your host supports IPv6, but it is misconfigured, which leads to this issue.

@gauthier-th
Copy link
Collaborator Author

@Gauvino we did some changes to try to fix this issue. Could you please try and see if it works now?

@Gauvino
Copy link
Contributor

Gauvino commented Jul 10, 2024

@Gauvino we did some changes to try to fix this issue. Could you please try and see if it works now?

Im gonna test this tonight, and will give feedback on everything !

@Gauvino
Copy link
Contributor

Gauvino commented Jul 10, 2024

Sorry for the news but nothing as change, all of the bugs are still there!

Does I can provide some logs are something to investigate more?

@gauthier-th gauthier-th marked this pull request as ready for review July 11, 2024 14:38
Copy link
Owner

@Fallenbagel Fallenbagel left a comment

Choose a reason for hiding this comment

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

LGTM!

@gauthier-th gauthier-th merged commit b36bb3f into develop Jul 14, 2024
9 checks passed
@gauthier-th gauthier-th deleted the switch-to-fetch-api branch August 24, 2024 12:44
@Fallenbagel
Copy link
Owner

🎉 This PR is included in version 2.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants