Closed NimaSoroush closed 9 months ago
Hi @NimaSoroush - as far as I remember, the domain library has been pending deprecation since node 6, but still on the pending state, while they finalize a replacement API: https://nodejs.org/dist/latest-v10.x/docs/api/domain.html I've been waiting for a long time for that, but still nothing new as far as I can tell.
This error looks interesting, as even in node 11 they mention the library is pending deprecation but yet should be there. For sure, if you are using node 8, that shouldn't be the case as I know of a number of people using node 8 in production with no issues.
Also, moving to webpack 4 shouldn't fix the issue as domain
is actually central to how OC renders components both in the client and the server, so that couldn't help.
Can you double check your error stack trace is not coming from something else?
Thanks
Hi @matteofigus , webpack 4 is not the solution, is the possible root cause! Although we are still investigating.
Yeah, we are using node 8 and OC for most of our components without any issue. The component that throws this error is the only one adapted webpack 4.
The stack trace coming from OC internal process but that might be just a side effect. I will update this post once I have more info
Hi @matteofigus , After investigating different scenarios:
This is only happening in one of our old component. Trying all above combination in a fresh OC and all works fine!
So what is the difference?! After looking into opencomponents/oc code and seeing what would make the old component different from fresh OC I found this const processData = context.module.exports.data
in https://github.com/opencomponents/oc/blob/b817be1e2f123dbde4265068aade58a0d3650d47/src/registry/routes/helpers/get-component.js#L475
This is generated by V8 Virtual Machine contexts. The old component exports default server
in server.js
which in plactice should be fine to be imported as data but for some reason when webpack bundles
webpack:4 and OC:0.45
...
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = "./src/server/server.js");
...
const server = (context, callback) => {
...
}
...
/* harmony default export */ __webpack_exports__["default"] = (server);
vs webpack:3 and OC:0.45
...
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = "./src/server/server.js");
...
const data = (context, callback) => {
...
}
...
/* harmony default export */ __webpack_exports__["default"] = (data);
So the quick resolution is to always export default data;
in server.js
of OCs. The proper fix would be to make neccessary changes to oc
and make it to respect to default exports
Closing this since there's still no alternative in the horizon, and it's not a problem per se. As the node documentation states:
Users who absolutely must have the functionality that domains provide may rely on it for the time being but should expect to have to migrate to a different solution in the future.
We must have the functionality, so when a solution appears, we'll migrate.
Who is the bug affecting?
Component creators
What is affected by this bug?
Node client
When does this occur?
in get-component.js > renderer() call
Where on the platform does it happen?
API
How do we replicate the issue?
Possibly by updating an OC component to use webpack 4
Expected behavior (i.e. solution)
The library should be replaced by a proper alternative or even better to rethink the current implementation
What version of OC, Node.js and OS are you using?
OC@v0.45.2 , Node v8.12.0, Mac
Other Comments
Deprecation note: https://nodejs.org/api/domain.html
error stack trace: