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

use internal fetch as replacement for node-fetch #3184

Merged
merged 2 commits into from
Sep 9, 2023

Conversation

khassel
Copy link
Collaborator

@khassel khassel commented Sep 7, 2023

related to #2649

I was able to move to internal fetch and all tests seems fine so far.

But we have one problem with the calendar module. In the docs we have several authentication methods and one of them is digest. For this we used digest-fetch which needs node-fetch (this is not so clear from code but I was not able to get it working).

So we have 3 options:

  • remove digest as authentication method for calendar module (this is what this PR does at the moment)
  • find an alternative npm package or implement the digest stuff ourselves
  • use digest-fetch and node-fetch for calendar module (so they would remain as dependencies in package.json)

Opinions? @KristjanESPERANTO @rejas @sdetweil @MichMich

@codecov-commenter
Copy link

codecov-commenter commented Sep 7, 2023

Codecov Report

Merging #3184 (63e4aa6) into develop (79e99e1) will decrease coverage by 0.09%.
Report is 1 commits behind head on develop.
The diff coverage is 100.00%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

@@             Coverage Diff             @@
##           develop    #3184      +/-   ##
===========================================
- Coverage    25.39%   25.31%   -0.09%     
===========================================
  Files           55       54       -1     
  Lines        11882    11852      -30     
===========================================
- Hits          3018     3000      -18     
+ Misses        8864     8852      -12     
Files Changed Coverage Δ
js/server_functions.js 90.83% <ø> (-0.08%) ⬇️
modules/default/newsfeed/newsfeedfetcher.js 82.96% <ø> (+0.45%) ⬆️
modules/default/calendar/calendarfetcher.js 93.19% <100.00%> (+0.29%) ⬆️

... and 2 files with indirect coverage changes

@rejas
Copy link
Collaborator

rejas commented Sep 8, 2023

Looks like digest-fetch fixed that with their latest release, but thats the v3 line where they switched to ESM.

I dont like removing stuff, so maybe we can provide either a patch for their v2 branch (if there is any) and ask them nicely if they want to release that too.

Or look for an alternative library...

Or is digest-auth so uncommon that we can remove it?

@khassel
Copy link
Collaborator Author

khassel commented Sep 8, 2023

Or is digest-auth so uncommon that we can remove it?

I don't know, I checked when it went to the doc-repo and this happened in the first commit, so I think that is in there because the request library supported it.

We have no tests for this and who knows if this ever worked after the change to digest-fetch ...

Will dig deeper and try to use the digest auth method with the current setup.

@khassel
Copy link
Collaborator Author

khassel commented Sep 8, 2023

I tried to setup a test for digest auth with current setup (node-fetch and digest-fetch).

Got it not working because this line in calendarfetcher.js will never work because digest is an async funtion and without the missing await you only get a pending promise back:

fetcher = new digest(auth.user, auth.pass).fetch(url, { headers: headers, agent: httpsAgent });

So I think we can remove digest auth because it has never worked since we replaced request.

I will make a documentation PR after this is merged.

@khassel khassel marked this pull request as ready for review September 8, 2023 19:29
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Show resolved Hide resolved
@khassel khassel requested a review from rejas September 9, 2023 17:45
@rejas rejas merged commit f2957f9 into MagicMirrorOrg:develop Sep 9, 2023
@khassel khassel deleted the internal-fetch branch September 9, 2023 19:40
@KristjanESPERANTO
Copy link
Contributor

@khassel, many thanks for this solid work! 🚀👏

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.

4 participants