-
Notifications
You must be signed in to change notification settings - Fork 8
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
fix: replace fetch with node-fetch to comply with ADR013 #38
Conversation
This is failing due to type check validations as |
@pcgqueiroz this is now passing all tests and validations. Can you check if this works from behind the proxy? If it makes it easier for you I have published the changes as version |
fetch
from node-fetch
package
@pcgqueiroz let me know once you have time to test this and if it works or not. Thanks! |
…-fetch refactor on response.json() after replacing fetch with node-fetch to cast unknown to specific type Signed-off-by: Tiago Barbosa <tbarbos@hotmail.com>
Signed-off-by: Tiago Barbosa <tbarbos@hotmail.com>
Signed-off-by: Tiago Barbosa <tbarbos@hotmail.com>
remove yarn state from repo as it should be generated on every new build Signed-off-by: Tiago Barbosa <tbarbos@hotmail.com>
@t1agob , I have tested with the package version /backstage/node_modules/@pagerduty/backstage-plugin-backend/dist/index.cjs.js:8
var fetch$1 = require('node-fetch');
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /backstage/node_modules/@pagerduty/backstage-plugin-backend/node_modules/node-fetch/src/index.js from /backstage/node_modules/@pagerduty/backstage-plugin-backend/dist/index.cjs.js not supported.
Instead change the require of index.js in /backstage/node_modules/@pagerduty/backstage-plugin-backend/dist/index.cjs.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (/backstage/node_modules/@pagerduty/backstage-plugin-backend/dist/index.cjs.js:8:15)
at @pagerduty/backstage-plugin-backend (/backstage/packages/backend/dist/main.js:577:18)
at __webpack_require__ (/backstage/packages/backend/dist/main.js:1090:33)
at fn (/backstage/packages/backend/dist/main.js:1301:21)
at eval (webpack-internal:///./src/plugins/pagerduty.ts:5:93)
at ./src/plugins/pagerduty.ts (/backstage/packages/backend/dist/src_plugins_pagerduty_ts.chunk.js:20:1)
at __webpack_require__ (/backstage/packages/backend/dist/main.js:1090:33)
at Function.fn (/backstage/packages/backend/dist/main.js:1301:21) {
code: 'ERR_REQUIRE_ESM'
} I suspect the error above is related to the node-fetch version |
@pcgqueiroz Oh...got it! This is due to the lack of support for ESM for backend modules in Backstage. Can you try it with version |
Signed-off-by: Tiago Barbosa <tbarbos@hotmail.com>
Hey @t1agob ! Version |
Description
This PR replaces global
fetch
withnode-fetch
library as recommended by Backstage on ADR013.This standardizes on the HTTP package used by the backend plugin and solves issue #37 that prevents HTTP calls to succeed behind a proxy.
Issue number: 37
Type of change
Checklist
If this is a breaking change 👇
Acknowledgement
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.