-
Notifications
You must be signed in to change notification settings - Fork 26
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
Limited functionality of custom middleware (Infinite loop when trying to handle HTTP request bodies) #344
Comments
I could reproduce the described issue. Next step would be to check whether this is also an issue when just using a middleware within |
Hi @matz3 i came accross the same problem now with a different middleware and can confirm a few things :
It seems that there is a delay after the csp middleware which ends up with the router getting out of the middleware stack and completing the request. |
@nlunets thanks for your input! I think this will really help further investigate into this issue. |
Hi @matz3 Regards |
I was able to isolate the issue by using |
Example to reproduce: https://github.com/matz3/connect-router-body-parser-issue |
I could now fully understand the scenario and will open an issue for the karma project to understand why those methods are called and to check how it could be solved. As mentioned above, karma calls |
Hi @matz3, I also have the same case in my current project:
and the app is started with the mockserver:
so karma successfully loaded my testrunner, but when the metadata of the mockserver is loaded there's an issue at currently I'm trying it with
|
@tiosteel as already stated above (#344 (comment)) using |
Using
|
Hi all,
Many thanks! |
When using a custom middleware in a SAP UI5 application as described here, the req and res objects handed over to the middleware are of different shape. Express-specific methods like res.status() oder res.header() do not exist (which can be worked around with native Node methods tough). However, I could not find a solution for the following problem:
POST Request bodies can't be handled at all; the middleware falls into an infinite loop when trying to read them via res.on('data', ...) or other stream reading methods (or encapsulating other middlewares/parsers like http-proxy, express.json(), bodyParser.json()). When using the Chromium browser, the request is aborted after exactly 20 oder 40 seconds, a postman request seems to have no timout and runs forever (until the execution of Karma is stopped).
When serving the application directly with the same UI5 configuration and middleware files, tests can be executed without problems.
Versions:
"karma": "^6.2.0",
"karma-ui5": "^2.3.3",
"express": "^4.17.1",
"@sap/ux-ui5-tooling": "^1.2.1",
"@ui5/cli": "^2.6.4",
"@ui5/fs": "2.0.3",
"@sap/grunt-sapui5-bestpractice-build": "^1.4.13",
"@sap/ux-specification": "^1.78.8",
"@ui5/logger": "2.0.0"
ui5-testing.yaml:
opatests.Qunit.html:
karma.conf.js:
I assume this is a bug, otherwise I would appreciate an explanation of what is exactly going on here under the hood and wheter there is a known workaroung. Thanks!
The text was updated successfully, but these errors were encountered: