WingZer0o
WingZer0o
DDeno
Created by WingZer0o on 5/12/2024 in #help
Postgres Deno Connection Pool Idle timeout
I am using NeonPostgres and connecting to the database in Deno using the following below and executing this way. This connection is running in a Discord bot using Discordeno. I am entirely ruling out local network setup however the discord bot itself never disconnects. So that brings me here. After a certain time frame that I haven't determined quite yet. Maybe 20 minutes or so?
import { Pool } from "https://deno.land/x/postgres@v0.19.3/mod.ts";

const pool = new Pool({
database: Deno.env.get("POSTGRES_DATABASE"),
hostname: Deno.env.get("POSTGRES_HOST"),
port: 5432,
user: Deno.env.get("POSTGRES_USER"),
password: Deno.env.get("POSTGRES_PASSWORD"),
connection: {
attempts: 10,
},
options: {

}
}, 10);
export { pool };

import { QueryArrayResult } from "https://deno.land/x/postgres@v0.19.3/mod.ts";
import { pool } from "../database/database.ts";

export class ChatMessageRepository {

public static async getChatMessagesByChannelIdAndUserId(channelId: bigint, userId: bigint): Promise<QueryArrayResult<unknown[]>> {
const client = await pool.connect();
const chatMesages = await client.queryArray(
`SELECT "Content", "IsBot" FROM public."ChatMessages" WHERE "ChannelId" = ${channelId} AND "UserId" = ${userId} ORDER BY "CreatedAt" ASC;`,
);
client.release();
return chatMesages;
}
}
import { Pool } from "https://deno.land/x/postgres@v0.19.3/mod.ts";

const pool = new Pool({
database: Deno.env.get("POSTGRES_DATABASE"),
hostname: Deno.env.get("POSTGRES_HOST"),
port: 5432,
user: Deno.env.get("POSTGRES_USER"),
password: Deno.env.get("POSTGRES_PASSWORD"),
connection: {
attempts: 10,
},
options: {

}
}, 10);
export { pool };

import { QueryArrayResult } from "https://deno.land/x/postgres@v0.19.3/mod.ts";
import { pool } from "../database/database.ts";

export class ChatMessageRepository {

public static async getChatMessagesByChannelIdAndUserId(channelId: bigint, userId: bigint): Promise<QueryArrayResult<unknown[]>> {
const client = await pool.connect();
const chatMesages = await client.queryArray(
`SELECT "Content", "IsBot" FROM public."ChatMessages" WHERE "ChannelId" = ${channelId} AND "UserId" = ${userId} ORDER BY "CreatedAt" ASC;`,
);
client.release();
return chatMesages;
}
}
ConnectionError: The session was terminated unexpectedly
0|chatbot | throw new ConnectionError("The session was terminated unexpectedly");
ConnectionError: The session was terminated unexpectedly
0|chatbot | throw new ConnectionError("The session was terminated unexpectedly");
2 replies
DDeno
Created by WingZer0o on 4/20/2024 in #help
Deno Bindgen
When attempting to follow the deno bindgen documentation I get errors about not being able to parse the cargo output or not being able to find symbols, I am basically following the example folder in the repo.
Is the deno_bindgen project ment to be installed locally as a cargo crate for the project so you can annotate the functions with deno_bindgen? Am I missing something in the documentation? If someone is knowledable about the crate I can post more error information.
3 replies
DDeno
Created by WingZer0o on 1/17/2024 in #help
Deno_bindgen
I'm super happy to see the Deno NPM compatibility supporting an FFI call using Rust's NAPI crate for a npm package I just made. I'd like to make a first class Deno TPM, is deno_bindgen ment to be installed as a crate within the FFI binding project or cloned and have the binding code moved into the cloned repo? The first seems more logical for me but I had some problems just executing simple binding generation. I can post a more specific error if its needed.
2 replies