node-sqlserver-v8 icon indicating copy to clipboard operation
node-sqlserver-v8 copied to clipboard

Unable to initialize msnodesql during Hot Module Reload (HMR)

Open CarlosOnline opened this issue 1 year ago • 3 comments

Looking for help on resolving Unable to initialize msnodesql error during HMR, using vite for electron.

Source: const msnodesqlv8 = require("mssql/msnodesqlv8");

Is there any reset or connection code I can apply to cause msnodesqlv8 to reload during HMR?

	void Connection::Init(Local<Object> exports) {
  		Nan::HandleScope scope;
		const auto initialized = OdbcConnection::InitializeEnvironment();
		const auto name = Nan::New("Connection").ToLocalChecked();
		if (!initialized) {
			const nodeTypeFactory fact;
			MutateJS::set_property_value(exports, name, Nan::Null());
			fact.throwError("Unable to initialize msnodesql");
			return;
		}

CarlosOnline avatar Dec 04 '23 04:12 CarlosOnline

Im sorry I am not aware how this can be solved. Can you try storing require on global and fetch back cached version is it related to second call to initialise. Ideally can you inject the same instance in every time. I’m really not an expert of the front end side of things.

TimelordUK avatar Dec 04 '23 18:12 TimelordUK

@CarlosOnline did you find any solution for this? Please share of you have ideas =)

MikeNitsenko avatar Dec 21 '23 09:12 MikeNitsenko