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

OpenUI5's legacy tooling breaks when linking to @ui5/server 1.1.0 #341

Closed
1 of 6 tasks
codeworrior opened this issue May 8, 2019 · 3 comments · Fixed by SAP/ui5-server#184
Closed
1 of 6 tasks
Assignees
Labels
bug Something isn't working module/ui5-server Related to the UI5 Server module

Comments

@codeworrior
Copy link
Member

Expected Behavior

When I link from openui5 to the latest release of the ui5-tooling, I expect that grunt serve continues to work.

Current Behavior

grunt serve starts but fails for each request and responds with an error stack trace (see below).
I unfortunately caused the issue myself with PR SAP/ui5-server#179 as I relied on express APIs in the csp middleware (request.path and request.params). But in the context of grunt serve, express is obviously not used and the APIs are missing.

Steps to reproduce the issue

  1. Clone openui5 and ui5-tooling
  2. Link from openui5 to @ui5/server at least
  3. Run grunt serve and open any HTML page

Affected components (if known)

Log Output / Stack Trace

TypeError: Cannot read property 'endsWith' of undefined
    at csp (/SAPDevelop/sapui5-dist/openui5/node_modules/@ui5/server/lib/middleware/csp.js:40:41)
    at call (/SAPDevelop/sapui5-dist/openui5/node_modules/connect/index.js:239:7)
    at next (/SAPDevelop/sapui5-dist/openui5/node_modules/connect/index.js:183:5)
    at /SAPDevelop/sapui5-dist/openui5/grunt/config/connect.js:130:7
    at call (/SAPDevelop/sapui5-dist/openui5/node_modules/connect/index.js:239:7)
    at next (/SAPDevelop/sapui5-dist/openui5/node_modules/connect/index.js:183:5)
    at Function.handle (/SAPDevelop/sapui5-dist/openui5/node_modules/connect/index.js:186:3)
    at Server.app (/SAPDevelop/sapui5-dist/openui5/node_modules/connect/index.js:51:37)
    at emitTwo (events.js:126:13)
    at Server.emit (events.js:214:7)
    at parserOnIncoming (_http_server.js:602:12)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:116:23)
@RandomByte
Copy link
Member

This is also a problem when using npm instead of yarn to install the dependencies in the OpenUI5 repository. Since we only provide a yarn.lock file, npm simply installs the latest version of all dependencies. So executing grunt serve after an npm install leads to the same endsWith error.

@codeworrior
Copy link
Member Author

Would it be an option to use express also in the grunt tooling or should we revert back to manual parsing of the params + path (using some other helpers, for sure - like it was done in the predecessor version of csp.js) or should we fix it in the grunt tooling by mocking the express functionality?

To me, reverting back seems to be the least expensive option.

@RandomByte
Copy link
Member

As discussed, let's revert back to manual parsing to keep compatibility with the current grunt tooling that is based on connect.

codeworrior referenced this issue in SAP/ui5-server May 11, 2019
With change 4f05967, the CSP middleware
made use of 'express' APIs on the request object. When used in an
environment without 'express' (e.g. the OpenUI5 legacy grunt tooling),
the CSP middleware failed for all requests.

It now uses the native NodeJS APIs again.

Fixes https://github.com/SAP/ui5-server/issues/183 .
codeworrior referenced this issue in SAP/ui5-server May 13, 2019
…ver (#184)

* [FIX] Makes CSP middleware work in an environment without express server

With change 4f05967, the CSP middleware
made use of 'express' APIs on the request object. When used in an
environment without 'express' (e.g. the OpenUI5 legacy grunt tooling),
the CSP middleware failed for all requests.

It now uses the native NodeJS APIs again.

Fixes https://github.com/SAP/ui5-server/issues/183 .

* adapt tests
@RandomByte RandomByte transferred this issue from SAP/ui5-server Nov 20, 2020
@RandomByte RandomByte added bug Something isn't working module/ui5-server Related to the UI5 Server module labels Nov 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working module/ui5-server Related to the UI5 Server module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants