-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
Hi dear MotherDuck team,
I am struggling to reauthenticate to Motherduck after entering an incorrect token.
The workflow is the following:
- I want to connect to MD
- I prompt the user to input his/her MD token
- The user gives a wrong token. I try to connect with
MDConnection.create. It fails as expected. - I tell the user to enter a correct token
- The user gives a correct token
- I again try to connect with
MDConnection.create. It fails unexpectedly
I saw in the docs that Multiple connections can be created. Connections share a DuckDB Wasm instance, so creating subsequent connections will not repeat the initialization process. Link
I can't close the connection as I can't get a working connection instance :(
This leads to the following unexpected behaviours:
- Creating a connection with a wrong token and then with a correct one leads to both connections not working
- Creating a connection with a right token and then with a wrong one still lets the 2nd one work
try {
const fakeToken = 'invalid'
const testConnection = MDConnection.create({
mdToken: fakeToken
});
const isInitialized = await testConnection.isInitialized();
console.log('Fake Token Initialized: ', isInitialized);
const versionResult = await testConnection.evaluateQuery("select version();");
const version = versionResult.data.singleValue();
console.log('Fake Token Motherduck version: ', version);
} catch (e) {
console.log('Fake token failed as expected. Error: ', (e as Error).message); <- This will be executed as expected
}
try {
const actualToken = 'actual_correct_token '
const testConnection = MDConnection.create({
mdToken: actualToken
});
const isInitalized = await testConnection.isInitialized();
console.log('Real Token Initialized: ', isInitalized);
const versionResult = await testConnection.evaluateQuery("select version();");
const version = versionResult.data.singleValue();
console.log('Real Token Motherduck version: ', version);
} catch (e) {
console.log('Real token failed. Error: ', (e as Error).message); <- It will still throw the unauth error here unexpected
}
try {
const actualToken = 'actual_correct_token '
const testConnection = MDConnection.create({
mdToken: actualToken
});
const isInitalized = await testConnection.isInitialized();
console.log('Real Token Initialized: ', isInitalized);
const versionResult = await testConnection.evaluateQuery("select version();");
const version = versionResult.data.singleValue();
console.log('Real Token Motherduck version: ', version); <- This is called as expected
} catch (e) {
console.log('Real token failed. Error: ', (e as Error).message);
}
try {
const fakeToken = 'invalid'
const testConnection = MDConnection.create({
mdToken: fakeToken
});
const isInitialized = await testConnection.isInitialized();
console.log('Fake Token Initialized: ', isInitialized);
const versionResult = await testConnection.evaluateQuery("select version();");
const version = versionResult.data.singleValue();
console.log('Fake Token Motherduck version: ', version); <- This is still working, but should not
} catch (e) {
console.log('Fake token failed as expected. Error: ', (e as Error).message);
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels