quickerquery 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +16 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -46,6 +46,7 @@ const App = ({ config }) => {
|
|
|
46
46
|
useEffect(() => {
|
|
47
47
|
if (state !== 'connecting')
|
|
48
48
|
return;
|
|
49
|
+
let isCancelled = false;
|
|
49
50
|
const newClient = new pg.Client({
|
|
50
51
|
host: config.host,
|
|
51
52
|
port: config.port,
|
|
@@ -56,17 +57,25 @@ const App = ({ config }) => {
|
|
|
56
57
|
newClient
|
|
57
58
|
.connect()
|
|
58
59
|
.then(() => {
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
if (!isCancelled) {
|
|
61
|
+
setClient(newClient);
|
|
62
|
+
setState('connected');
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
// Connection completed but we've moved on, close it
|
|
66
|
+
newClient.end().catch(() => { });
|
|
67
|
+
}
|
|
61
68
|
})
|
|
62
69
|
.catch((err) => {
|
|
63
|
-
|
|
64
|
-
|
|
70
|
+
if (!isCancelled) {
|
|
71
|
+
setError(err.message);
|
|
72
|
+
setState('error');
|
|
73
|
+
}
|
|
65
74
|
});
|
|
66
75
|
return () => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
76
|
+
isCancelled = true;
|
|
77
|
+
// Don't close newClient here - if connection succeeds,
|
|
78
|
+
// it will be stored in state and closed on app exit
|
|
70
79
|
};
|
|
71
80
|
}, [state, config, username, password]);
|
|
72
81
|
const handleQuerySubmit = async () => {
|