0

Running deno v1.1.0 and using deno-postgres

Database is configured like so

import { Client } from "https://deno.land/x/postgres/mod.ts";

class Database {

  client?: Client;

  constructor() {
    this.connect();
  }

  async connect() {
    this.client = new Client({
      user: "someuser",
      database: "somedb",
      hostname: "somehost",
      password: "somepassword",
      port: 5432,
    });
    await this.client.connect();
  }
}

export default new Database().client;

But when I try to startup my app, I keep running into this error:

Listening on port 7700 ...
error: Uncaught Error: Another accept task is ongoing
    at unwrapResponse ($deno$/ops/dispatch_json.ts:43:11)
    at Object.sendAsync ($deno$/ops/dispatch_json.ts:98:10)
    at async ListenerImpl.accept ($deno$/net.ts:63:17)
    at async Server.acceptConnAndIterateHttpRequests (https://deno.land/std@0.56.0/http/server.ts:212:14)
    at async MuxAsyncIterator.callIteratorNext (https://deno.land/std@0.56.0/async/mux_async_iterator.ts:28:29)
avion
  • 1
  • 1
  • This error occurs when you (or the library you are using) are awaiting `listener.accept()` while you attempt to call another `listener.accept()` again (I wrote this error message so I'm pretty confident that this is the concrete issue) – Kevin Qian Jun 24 '20 at 05:25

1 Answers1

0

Update! Changed my database file to this and it works now:

import { Client } from "https://deno.land/x/postgres/mod.ts";

const client = new Client({
    user: "someuser",
    database: "somedatabase",
    hostname: "somehost",
    password: "somepassword",
    port: 5432,
});

await client.connect();

export default client;
avion
  • 1
  • 1