-
Notifications
You must be signed in to change notification settings - Fork 71
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
Replace request and xhr with axios #230
Replace request and xhr with axios #230
Conversation
Thanks. Can you remove the file changes to ./dist please? |
I thought the wasm must be recompiled for this to work. Or you want to recompile yourself? Dist .js files contain old logic too |
a083e9f
to
735644c
Compare
Yeah I always update the dist files at the end of the release on the master branch, since they contain large binaries and other generated artifacts which don't need to be in the repository, and which can cause merge conflicts on rebasing/testing with other commits. It also makes it easier to view the diffs. |
735644c
to
f8cb5c6
Compare
f8cb5c6
to
3ead35f
Compare
Fixed handling of binary requests and responses, thoroughly tested on both daemon and wallet-rpc being auth-protected. |
src/test/Axios.ts
Outdated
import { createWalletFull, MoneroNetworkType, MoneroWalletListener } from "../.."; | ||
import { connectToWalletRpc } from "../.."; | ||
|
||
describe("Axios", function() { |
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.
Thanks, but let's actually remove this test, since it's redundant with existing tests like the sample code.
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.
agree
src/test/TestAll.ts
Outdated
@@ -57,3 +57,5 @@ new TestMoneroConnectionManager().runTests(); | |||
|
|||
// test scratchpad | |||
require("./Scratchpad"); | |||
|
|||
require("./Axios"); |
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.
Can remove this too.
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.
agree
I'm getting an error building the dist files myself, specifically the web worker:
This is after deleting ./build, ./browser_build, and ./node_modules, running |
Yeah I had this error. I had to do:
Maybe it is the quirk of new emscription? It seemingly have nothing to do with my changes |
That did the trick :) |
Hm, it's strange though. I get this error every time running ./bin/build_dist.sh without first deleting the dist directory. But this behavior only happens with this PR applied. Otherwise it always works. We're going to have to figure this out before I can incorporate this change, unfortunately. |
3ead35f
to
69fbe96
Compare
Can confirm this on master, after removing new redundant axios tests the issue went away. Please try again. I have omitted pushing dist changes as you asked |
That works :) |
perfect |
The tests are all working, except one failure on "Can manage connections", which passes on master. In case it's related, this part of the code is making requests to multiple monero-wallet-rpc servers simultaneously, in order to test getting the best connection. The easiest way to run this test is in Node.js, with If you want to run the test in the browser, run |
Fixed the failing test. My observation: But if it is indeed daemon it asks for first 100 blocks which might be a bit too heavy for a connection check. Maybe something like |
Yeah it assumes a connection to monerod (almost always true), and falls back to treating a 404 as connected and uses the latency check.
The idea is to get a measurement which reflects if the node is under load, with the first 100 blocks being relatively light compared to later blocks for fully syncing the wallet. |
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.
Everything works. Just some final cleanup requested.
src/main/ts/common/HttpClient.ts
Outdated
|
||
// normalize response | ||
let normalizedResponse: any = {}; | ||
|
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.
Remove empty line
src/main/ts/common/HttpClient.ts
Outdated
|
||
normalizedResponse.statusCode = resp.status; | ||
normalizedResponse.statusText = resp.statusText; | ||
|
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.
Remove empty line
src/main/ts/common/HttpClient.ts
Outdated
@@ -200,7 +119,7 @@ export default class HttpClient { | |||
}); | |||
return HttpClient.HTTPS_AGENT; | |||
} | |||
|
|||
protected static parseXhrResponseHeaders(headersStr) { |
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.
This function can be removed completely now.
const randNum = Math.round(Math.random() * characters.length); | ||
token += characters.slice(randNum, randNum+1); | ||
} | ||
return token; | ||
} | ||
|
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.
Remove extra empty line
Done |
Resolves #95