-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Update node-fetch in the API to fix connection drop issue #1397
Merged
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c20a8fd
Add yet more error logging
j-f1 09a2437
Add release note
j-f1 e6d3ae0
Update to node-fetch 3
j-f1 e2a9329
ignore API stats.json file
j-f1 f0902ec
Update release note
j-f1 fbdc5af
Remove unused fetchBinary
j-f1 de09fca
Fix require() of esm error
j-f1 553b585
Fix import() transform
j-f1 9486ef1
swap self for globalThis
j-f1 24d8d7e
Add build:api global script
j-f1 2111a85
Fix api/test.js
j-f1 74db110
Fix lint error
j-f1 2f6e090
Delete test.js
j-f1 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 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 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
app/bundle.api.js* | ||
app/stats.json | ||
migrations | ||
default-db.sqlite |
This file contains 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 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 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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import * as api from './index'; | ||
let api = require('./dist/index'); | ||
|
||
async function run() { | ||
let app = await api.init({ config: { dataDir: '/tmp' } }); | ||
let app = await api.init({ dataDir: '/tmp' }); | ||
await app.send('create-budget', { testMode: true }); | ||
await api.shutdown(); | ||
} | ||
|
||
run(); |
This file contains 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 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 @@ | ||
export const fetch = globalThis.fetch; |
This file contains 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
20 changes: 1 addition & 19 deletions
20
packages/loot-core/src/platform/server/fetch/index.electron.ts
This file contains 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 |
---|---|---|
@@ -1,19 +1 @@ | ||
import * as fs from 'fs'; | ||
|
||
import fetch from 'node-fetch'; | ||
|
||
export { fetch }; | ||
|
||
export const fetchBinary = async function (url, filepath) { | ||
const res = await fetch(url); | ||
return new Promise((resolve, reject) => { | ||
const fileStream = fs.createWriteStream(filepath); | ||
res.body.pipe(fileStream); | ||
res.body.on('error', err => { | ||
reject(err); | ||
}); | ||
fileStream.on('finish', function () { | ||
resolve(undefined); | ||
}); | ||
}); | ||
}; | ||
export { default as fetch } from 'node-fetch'; |
4 changes: 0 additions & 4 deletions
4
packages/loot-core/src/platform/server/fetch/index.testing.ts
This file contains 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 |
---|---|---|
@@ -1,7 +1,3 @@ | ||
export const fetch = function () { | ||
throw new Error('fetch not implemented'); | ||
}; | ||
|
||
export const fetchBinary = function () { | ||
throw new Error('fetchBinary not implemented'); | ||
}; |
This file contains 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 |
---|---|---|
@@ -1,5 +1 @@ | ||
export const fetch = self.fetch; | ||
|
||
export const fetchBinary = function () { | ||
throw new Error('fetchBinary not implemented'); | ||
}; | ||
export const fetch = globalThis.fetch; |
This file contains 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 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,6 @@ | ||
--- | ||
category: Bugfix | ||
authors: [j-f1] | ||
--- | ||
|
||
Update the API’s `node-fetch` dependency to fix a bug where connections could unexpectedly fail |
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests shouldn't rely on the compiled code, but instead the source. Any way we can change this back?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO this should be testing the compiled code to make sure that it actually behaves correctly. It isn’t automatically run at this point (#1074) but running directly against the source somehow could give us false confidence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually.. this file is not even used. So I would vote to kill it off entirely.
Even when we add proper tests to api: it won't really make much sense since it's not really a unit test or a e2e test. Just some weird leftover I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥