I've created up a nodejs mono-repo project using tuborepo and the kitchen-sink template.
Here I have some applications, the code that I am going to release, and some packages, basically are shared functions and logic that the applications may or may not use.
It worked well, until some days ago, when I've found a strage behavior in some of my apps.
I have to make some changes to an application, so I've opened up Visual Studio Code, I've run yarn dev, and I was ready to code, but when I've started the application that need to update, I've noticed that it won't start, usually it takes some time, like 5 seconds at most, but this time it was taking up to 30-40 seconds util the node process exited.
I've tried with another application that is very similar but differs in some way, and I've encountered the same issue, so I've decided to create and empty test suite check if everything was still working fine, and it did, I mean the node process was not crashing and I've had the output I expected.
Then I've started to import from the packages the modules I needed, and I've noticed that a particular one causes this weird problem.
This module depends on other packages, and its main purpose is to serve up classes and functions that may be use from the application.
The problem is: when use the import ... from ... from the application code, the process hangs, then sometimes it can start properly so the code is executed, sometimes the node process exits, without an error message and with a status code of 0.
I've tried to use the process.on("uncaughtException") and process.on("unhandledException") but neither of them are ever fired, segault-handler doesn't help either since it does not report anything.
I've checked the code of this module, and it does not execute some functions or perform logic while it is importing, so I don't think it has to do with slow running functions.
I have only one theory, circular dependencies so a js file to includes another js file which itself includes the first one? but I don't think so since the code used to work just fine.
I've to use a backup of the code I have when It worked, but still, I do have the same error
I was wondering guys if you could please give me some hints to fix the bug, or if you had a similar issue explain how to solve.
Related
I am creating an automation testing platform, and I wrote a code which executes around 300+ tests in a row.
I am currently running the tests on my local machine. After around 10-20 tests the testcafe either stops working or giving false error or starts slowing down and not navigating to the right page therefore can't find any of the selectors I tell it to look for.
I know this to be false errors since when I only run these tests on their own testcafe is not doing that anymore and the tests pass successfully with no errors at all.
Any idea whats going on? Is this a problem with my local machine?
The cause of the issue is unclear. Please create a separate issue using the following link https://github.com/DevExpress/testcafe/issues/new?assignees=&labels=TYPE%3A+bug&template=bug_report.yaml and share an example that demonstrates the issue.
OK I found the issue in my code. I took a lot of screenshots per test and didn't clear them after each run which inflated my memory causing node and testcafe to crash.
Thanks for all the help
I have an emscripten/webassembly wrapped C++ class that launches and uses pthreads internally. It generally works fine when used in javascript on Chrome in its stand-alone development sandbox. However, I can't really get it to work with create-react-app and webpack (i.e. I used react-app-rewired to be able to configure webpack).
The problem seems to be from the complexity of the javascript and wasm files that a threaded emscripten build creates, and the confusion those scripts have due to the renaming of files that webpack produces. The files produced for a multi-threaded emscipten build are:
MyModule.js
MyModule.wasm
MyModule.worker.js
I can (I think) get it to work in the non-threaded mode where there is just a MyModule.js and a MyModule.wasm file through the use of the Module's locateFile method. However, the system gets very confused due to the introduction of the new MyModule.worker.js file which the MyModule.js file launches on its own within a WebWorker. And of course the MyModule.worker.js file needs to also find and get access to MyModule.wasm, and that gets lost too (i.e. can't find the right file name due to the webpack renaming).
Anyway, I've spent hours searching the web for any successful use cases like this, and trying may things, including manually editing the MyModule.js and MyModule.worker.js files, but without any luck so far.
Has anyone successfully tried something like this, or any other advice on getting a multi-threaded emscripten/wasm build to run properly with webpack (or create-react-app)? Any advice would be greatly appreciated.
NOTE: This question isn't about running a emscripten/webassembly module in a web-worker thread (although in the end I'm going to run all this in a web-worker). Its specifically about a multi-threaded emscripten build (i.e. C++ with pthreads) launching and running properly with webpack.
In Module's locateFile, you should return the correct path for MyModule.wasm and MyModule.worker.js.
Besides, In Module's mainScriptUrlOrBlob, you should assign the path for MyModule.js.
The mainScriptUrlOrBlob is used in worker for loading the wasm.
I am working on node js application and it is now ready to use. I want to make exe of this application so that it can be used for commercial usage.
Up to now I have used enclose module using which I have compiled the code of application but I have found some issues in that (app got crash on idle condition). App is running good without enclose or compiled code.
I have searched on google and found some alternate modules like JXcore, Node webkit and Electron etc. but JX core giving error same as in SO question.
In node web-kit, it's functionality is not looking suitable as we need its executable and some dll's along with our code, which makes our package bulky.
I have also tried jxcore. The main problem with the exe's and with modules that we use is their ability to work with native modules, in my case the Kinect.node module. This module cannot be compiled. We need a workaround to package only this along with our .exe file. Enclose provides this workaround in its inbuilt functionality.
Also looking a response from EncloseJS, which is actually run by just one person who gives further instructions upon purchase. A purchase is needed for commercial usage.
In case of Electron, It is supporting only Electron-based application source code. So If I choose this then I have to modify my application code.
So can any one suggest me what can I do to make exe file from node js code there?
Thank you!
I had the same issue before, the node js application close when running in background. now i am using process manager2 (pm2), it is working fine and if the application is crash due to any other reason it is automatically started again.
I have gotten my answer:
First, reason was DiskDB database, it was not compatible with the node webkit so that is why I was getting error of native modules.
Now I am using sqlite3 module for local database. It is better than DiskDB.
Second, One reason was free version of enclose, Paid version of Enclose JS module ignores the timeout issue which I was getting.
This way I have resolved my question.
I have a Koa application that has a multipart/form-data file upload that has suddenly stopped working. I have spent over 8 hours now trying to isolate the issue. What I've tried/verified:
Not a Node 6 issue; same problem occurs with Node 4 (which was previously working).
Have ruled out version issues in packages.json; have tested against originally working versions of all relevant packages, and latest versions.
Issue exhibits in latest Chrome and latest Firefox.
Issue does NOT exhibit when POSTing directly from Postman with exact same headers as browser is sending (excepting Cookie and Referer, neither of which can be set in Postman).
Problem exhibits with Koa wrappers koa-better-body and koa-multer.
Problem exhibits when directly using busboy, formidable, and even multiparty.
Similar to problems people were reporitng on this multer issue; tried all suggestions (including the long shot of adding field parameters before file parameter) to no avail.
Have tried to recreate minimal test case to reproduce, but have been unable to.
Have tried whittling down my app line by line, examining Babel output against minimal test case until they are functionally identical, problem still persists in my app, but not in test case.
All tests running on the same server, with the same browsers.
When debugging, the cleanest view of the problem is with formidable, in incoming_form.js. A single data event occurs:
Then an abort event:
After that, the browser eventually times out. (The file is larger than the 15 bytes being received in the first data event.)
I had hoped for a quick fix by switching from formidabl to busboy, and now I am a real bind, because this problem needs to get fixed, and I am running out of ways to look at the problem. I've tried to slice it every way I can think of, debug it every way I can think of, and short of writing my own multipart parser (not a task I would relish), I'm fast running out of options.
Has anyone run across this? Do you have any ideas how I might proceed with debugging or producing a minimum test case?
It turns out the issue was with koa-proxy: it doesn't correctly forward multipart POST requests. I fixed it by switching to koa-proxy2, and I will look into contributing a fix to the koa-proxy project.
Seeing how node.js is ultimately javascript, shouldn't changes to any files be seen when trying to run the app command? I've forked the yuidocjs repo on github and am trying to work my way through my local build, but for some reason my minor changes do not get picked up. I'm new to node.js so I'm not really sure what the exact conventions are.
In node.js when you require a file the source code gets interpreted. It's considered good practice to require all code when you start the server so all the code gets interpreted once.
The code does not get re-interpreted whenever you run it though.
So changes are not instantaneous.
To help you out, try supervisor which does hot reloading of the server on code changes.
It is possible to make instant changes happen by re-interpreting source code but that is not the default action. Generally you should just re-start the server.
Also see nodemon which will automagically reload changed files under it's authority.
EDIT
Rereading your question, it appears you are asking about the following scenario:
Run app to test
Quit app to refactor js code
Restart app
And you're asking why your changes do not appear at step 3?
If this is the case, you are seeing something very strange which might be related to how and from where files are being required.
In node, run:
console.dir(require.paths);
To see where node is looking for any resources you are requiring. If there is a copy of the file you're changing in any of the paths listed which is not the file you're editing, this would explain your problem.