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.
Files changed (2) hide show
  1. package/dist/index.js +16 -7
  2. 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
- setClient(newClient);
60
- setState('connected');
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
- setError(err.message);
64
- setState('error');
70
+ if (!isCancelled) {
71
+ setError(err.message);
72
+ setState('error');
73
+ }
65
74
  });
66
75
  return () => {
67
- if (newClient) {
68
- newClient.end().catch(() => { });
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 () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quickerquery",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "A terminal-based database query tool inspired by JetBrains DataGrip",
5
5
  "license": "MIT",
6
6
  "type": "module",