Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix(lib): circular dependency index.js <-> lib pool.js and pool_connection.js required index.js, and index.js required pool.js and pool_connection.js. Circular dependency can cause all sorts of problems. This fix aims to provide a step towards fixing a problem with @opentelemetry/instrumentation-mysql2, which looses several exports when using its patched require. For instance, `format` is lost and can cause an instrumented application to crash. * fix: circular dependency index.js <-> promise.js index.js and promise.js require each other. Circular dependency can cause all sorts of problems. This commit aims to fix a problem with @opentelemetry/instrumentation-mysql2, which looses several exports when using its patched require. For instance, `format` is lost and can cause an instrumented application to crash. * refactor: split common.js into lib modules The proposal to put common.js into lib was good, but it felt weird to arbitrarily stuff just some exported functions in lib/common.js. This made sense when common.js was meant to provide commons for index.js and promise.js. But in the lib, this felt like a weird scope. I therefore split common.js into - lib/create_connection.js - lib/create_pool.js - lib/create_pool_cluster.js Also made `require` more consistent in all affected files: all `require` files now have a js suffix when they refer to a single local file. * fix: circular dependency to promise.js promise.js was required by lib sources, and promise.js required the same lib sources eventually. Extracted the respective classes to lib. Also extracted functions that are shared between several of the new files. Decided to put each exported class / function into its own file. This may bloat the lib folder a bit, but it provides clarity (where to find what). * fix: missing patched functions The extraction of classes was performed without extracting the patch of methods like `escape`, etc. The patching is now performed in the files that define the respective classes, guaranteeing patched versions when these files are required. * chore: remove unused require * style: add missing semicolons and file name suffixes for require Co-authored-by: mknj <[email protected]> * chore: resolve all remaining circular dependencies * chore: better organize new files --------- Co-authored-by: mknj <[email protected]> Co-authored-by: wellwelwel <[email protected]>
- Loading branch information