node-soap
node-soap copied to clipboard
Improve trim speed during XML parsing.
- Use native string.trim instead of regex replace for performance.
- Add tests surrounding trim function used in wsdl parsing.
Issue with parsing large XML responses
I recently noticed an issue with slow parsing of large (1-2mb+) responses. I narrowed the issue down to the trim(text) method in wdsl/index.ts This uses regex to remove whitespace characters at the start and end of a string. This has performance implications when the string is very long, as I believe the trimRight regex needs to scan the entire content before reaching the end and then backtrack.
This issue was so bad it was causing requests to timeout after (10+ minutes).
Solution
I couldn't see any other tests testing the whitespace removal, so I added some. I validated that it was extremely slow before the change (I gave up waiting after around 5 minutes). I validated that after the change it was fast (~10ms). And that the expected output is the same.
Tested the PR out and also saw a huge improvement in performance. 👌
Just wondering if this project is being maintained anymore? I don't see any activity from the listed maintainers.
Another PR that seems quite important and supported isn't merged either (another issue I just ran into which brought me back here) - #1212
I ended up just forking the project and hosting it on my own package feed, but I figured there would have been some activity in the past few months.
Good one, thanks for submitting it, I will include in the next release.