node@19.6.0
nodemon@2.0.20
mariadb@3.1.0
MariaDB SQL server: 10.10.3
MariaDB SQL server in a docker container. Tested with both node & nodemon. OS: Windows 10
Description
If Node w/mariadb connector & mariadb server losses connection between them, an 'UncaughtException' error will happen. Maybe I'm too new at this, but it seems like there might be an error in the createPool. Desire is to catch the error and let the pool try to reconnect in X time.
Assuming "ClientOptions" are valid and MariaDB server is running, the following will create a pool in Node.js:
const pool = mariadb.createPool(clientOptions)
That is working, but if I simulate that the MariaDB server dies/losing connection (i.e. stops the docker container):
Node will crash after a few seconds with an 'UncaughtException' error.
Seems like createPool is not a promise itself, but it's service is. So not sure how to catch the error and let it try to connect again in X time.
I have tried to listen to events:
pool.on('error' ... This gives a error message 'ECONNREFUSED'
process.on('uncaughtException' ... This gives a error message 'ECONNREFUSED'
In both cases Node.js exits, and there seems no possible way to recover from this (beside PM2 or forever; not tested these)
Error: connect ECONNREFUSED ::1:3306
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16)
From event:
at D:\Code\node-db-boilerplate\node_modules\mariadb\lib\connection.js:133:13
at new Promise (<anonymous>)
at Connection.connect (D:\Code\node-db-boilerplate\node_modules\mariadb\lib\connection.js:121:12)
at Pool._createConnection (D:\Code\node-db-boilerplate\node_modules\mariadb\lib\pool.js:402:16)
at Pool._doCreateConnection (D:\Code\node-db-boilerplate\node_modules\mariadb\lib\pool.js:40:10)
at listOnTimeout (node:internal/timers:568:17)
at process.processTimers (node:internal/timers:511:7)
Emitted 'error' event on PoolPromise instance at:
at Pool.emit (node:events:512:28)
at D:\Code\node-db-boilerplate\node_modules\mariadb\lib\pool.js:258:22
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Closing it dupplicate of CONJS-246 that will be corrected in next version.
About minor, you're kind, i've set it as a blocker, since crashing application is serious, even if workaround is easy to implement.
Diego Dupin
added a comment - Closing it dupplicate of CONJS-246 that will be corrected in next version.
About minor, you're kind, i've set it as a blocker, since crashing application is serious, even if workaround is easy to implement.
People
Diego Dupin
Rino Rabe
Votes:
0Vote for this issue
Watchers:
2Start watching this issue
Dates
Created:
Updated:
Resolved:
Git Integration
Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.
{"report":{"fcp":855.7999997138977,"ttfb":193.19999980926514,"pageVisibility":"visible","entityId":119683,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"6d331f67-94cd-4f4f-886d-cef2e5dcb7ab","navigationType":0,"readyForUser":926.0999999046326,"redirectCount":0,"resourceLoadedEnd":1045.5,"resourceLoadedStart":205,"resourceTiming":[{"duration":83.09999990463257,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":205,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":205,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":288.09999990463257,"responseStart":0,"secureConnectionStart":0},{"duration":83.09999990463257,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/2bf333562ca6724060a9d5f1535471f6/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":205.2999997138977,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":205.2999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":288.3999996185303,"responseStart":0,"secureConnectionStart":0},{"duration":99.40000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":205.39999961853027,"connectEnd":205.39999961853027,"connectStart":205.39999961853027,"domainLookupEnd":205.39999961853027,"domainLookupStart":205.39999961853027,"fetchStart":205.39999961853027,"redirectEnd":0,"redirectStart":0,"requestStart":205.39999961853027,"responseEnd":304.7999997138977,"responseStart":304.7999997138977,"secureConnectionStart":205.39999961853027},{"duration":173.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/2bf333562ca6724060a9d5f1535471f6/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":205.59999990463257,"connectEnd":205.59999990463257,"connectStart":205.59999990463257,"domainLookupEnd":205.59999990463257,"domainLookupStart":205.59999990463257,"fetchStart":205.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":205.59999990463257,"responseEnd":379.09999990463257,"responseStart":379.09999990463257,"secureConnectionStart":205.59999990463257},{"duration":177.30000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/a9324d6758d385eb45c462685ad88f1d-CDN/lu2cib/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":205.7999997138977,"connectEnd":205.7999997138977,"connectStart":205.7999997138977,"domainLookupEnd":205.7999997138977,"domainLookupStart":205.7999997138977,"fetchStart":205.7999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":205.7999997138977,"responseEnd":383.09999990463257,"responseStart":383.09999990463257,"secureConnectionStart":205.7999997138977},{"duration":177.59999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":206,"connectEnd":206,"connectStart":206,"domainLookupEnd":206,"domainLookupStart":206,"fetchStart":206,"redirectEnd":0,"redirectStart":0,"requestStart":206,"responseEnd":383.59999990463257,"responseStart":383.59999990463257,"secureConnectionStart":206},{"duration":177.90000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":206.19999980926514,"connectEnd":206.19999980926514,"connectStart":206.19999980926514,"domainLookupEnd":206.19999980926514,"domainLookupStart":206.19999980926514,"fetchStart":206.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":206.19999980926514,"responseEnd":384.09999990463257,"responseStart":384.09999990463257,"secureConnectionStart":206.19999980926514},{"duration":255.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2cib/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":206.2999997138977,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":206.2999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":461.7999997138977,"responseStart":0,"secureConnectionStart":0},{"duration":178.19999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":206.5,"connectEnd":206.5,"connectStart":206.5,"domainLookupEnd":206.5,"domainLookupStart":206.5,"fetchStart":206.5,"redirectEnd":0,"redirectStart":0,"requestStart":206.5,"responseEnd":384.69999980926514,"responseStart":384.69999980926514,"secureConnectionStart":206.5},{"duration":255.2999997138977,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2cib/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":206.59999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":206.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":461.8999996185303,"responseStart":0,"secureConnectionStart":0},{"duration":178.59999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/s/5d5e8fe91fbc506585e83ea3b62ccc4b-CDN/lu2cib/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":206.7999997138977,"connectEnd":206.7999997138977,"connectStart":206.7999997138977,"domainLookupEnd":206.7999997138977,"domainLookupStart":206.7999997138977,"fetchStart":206.7999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":206.7999997138977,"responseEnd":385.3999996185303,"responseStart":385.3999996185303,"secureConnectionStart":206.7999997138977},{"duration":821.6999998092651,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":207.59999990463257,"connectEnd":207.59999990463257,"connectStart":207.59999990463257,"domainLookupEnd":207.59999990463257,"domainLookupStart":207.59999990463257,"fetchStart":207.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":207.59999990463257,"responseEnd":1029.2999997138977,"responseStart":1029.2999997138977,"secureConnectionStart":207.59999990463257},{"duration":822,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":207.69999980926514,"connectEnd":207.69999980926514,"connectStart":207.69999980926514,"domainLookupEnd":207.69999980926514,"domainLookupStart":207.69999980926514,"fetchStart":207.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":207.69999980926514,"responseEnd":1029.6999998092651,"responseStart":1029.6999998092651,"secureConnectionStart":207.69999980926514},{"duration":120.09999990463257,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":500.19999980926514,"connectEnd":500.19999980926514,"connectStart":500.19999980926514,"domainLookupEnd":500.19999980926514,"domainLookupStart":500.19999980926514,"fetchStart":500.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":500.19999980926514,"responseEnd":620.2999997138977,"responseStart":620.2999997138977,"secureConnectionStart":500.19999980926514},{"duration":241.09999990463257,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2cib/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/css/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":803,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":803,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1044.0999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":235,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/e65b778d185daf5aee24936755b43da6/_/download/contextbatch/js/browser-metrics-plugin.contrib,-_super,-project.issue.navigator,-jira.view.issue,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":804,"connectEnd":804,"connectStart":804,"domainLookupEnd":804,"domainLookupStart":804,"fetchStart":804,"redirectEnd":0,"redirectStart":0,"requestStart":804,"responseEnd":1039,"responseStart":1038.8999996185303,"secureConnectionStart":804},{"duration":248.60000038146973,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":846.3999996185303,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":846.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1095,"responseStart":0,"secureConnectionStart":0},{"duration":241.10000038146973,"initiatorType":"script","name":"https://jira.mariadb.org/s/097ae97cb8fbec7d6ea4bbb1f26955b9-CDN/lu2cib/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/js/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":804.3999996185303,"connectEnd":804.3999996185303,"connectStart":804.3999996185303,"domainLookupEnd":804.3999996185303,"domainLookupStart":804.3999996185303,"fetchStart":804.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":804.3999996185303,"responseEnd":1045.5,"responseStart":1045.5,"secureConnectionStart":804.3999996185303}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":37,"responseStart":193,"responseEnd":195,"domLoading":203,"domInteractive":1054,"domContentLoadedEventStart":1054,"domContentLoadedEventEnd":1094,"domComplete":1395,"loadEventStart":1396,"loadEventEnd":1396,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1032.5},{"name":"bigPipe.sidebar-id.end","time":1033.2999997138977},{"name":"bigPipe.activity-panel-pipe-id.start","time":1033.5},{"name":"bigPipe.activity-panel-pipe-id.end","time":1034.3999996185303},{"name":"activityTabFullyLoaded","time":1107.2999997138977}],"measures":[],"correlationId":"2488b08f78a4c7","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":104,"dbReadsTimeInMs":14,"dbConnsTimeInMs":22,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
Setting the priority to 'Minor' as I've succesfully managed to use events to intercept the crash error (and handle it).