I have angular v18 ssr when trying to connect to mongodb it gives errors about " whatwg-url"

@Kushagra_Kesav update 2
i managed to solve the issue related to whtwg-url package by the help the of chatgpt
first i located the error in node_modules>whatwg-url/liv>lib>utils.js
the error comes from this line of code

const AsyncIteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf(async function* () {}).prototype);

it gives undefined for some reason
chatgpt code

let AsyncIteratorPrototype;

try {
    // Check if async generator functions are supported
    const asyncGenFunction = async function* () {};
    // Verify that the async generator function has a prototype
    if (asyncGenFunction.prototype) {
        // Access AsyncIteratorPrototype
        AsyncIteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf(asyncGenFunction.prototype));
    } else {
        throw new Error('Async generators are not supported in this environment.');
    }
} catch (error) {
    console.error('Failed to assign AsyncIteratorPrototype:', error);
    // Provide a fallback or handle the error as needed
    AsyncIteratorPrototype = null; // Assigning null as a fallback
}

and it solved the issue
here chatgpt full chat/response
chatgpt response
i omitted export {AsyncIteratorPrototype} because its used locally in same file

please inform whatwp-url devs to modify the package
note => after changing the code in utils file and tested it in normal express mongodb only env. and it works as well

1 Like