usb 2.7.0 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.8.0] - 2023-02-11
4
+
5
+ ### Changed
6
+ - Minor tweaks to avoid some race conditions - [`569`](https://github.com/node-usb/node-usb/pull/569) ([Rob Moran](https://github.com/thegecko))
7
+
3
8
  ## [2.7.0] - 2023-01-25
4
9
 
5
10
  ### Fixed
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "usb",
3
3
  "description": "Library to access USB devices",
4
4
  "license": "MIT",
5
- "version": "2.7.0",
5
+ "version": "2.8.0",
6
6
  "main": "dist/index.js",
7
7
  "engines": {
8
8
  "node": ">=10.20.0 <11.x || >=12.17.0 <13.0 || >=14.0.0"
Binary file
Binary file
Binary file
@@ -80,6 +80,7 @@ class HotPlugManagerWindows : public HotPlugManager
80
80
  {
81
81
  public:
82
82
  HotPlugManagerWindows()
83
+ : hcm(nullptr)
83
84
  {
84
85
  cmNotifyFilter = { 0 };
85
86
  cmNotifyFilter.cbSize = sizeof(cmNotifyFilter);
@@ -105,6 +106,7 @@ public:
105
106
  auto res = CM_Register_Notification(&cmNotifyFilter, (PVOID)instanceData, (PCM_NOTIFY_CALLBACK)&MyCMInterfaceNotification, &hcm);
106
107
  if (res != CR_SUCCESS)
107
108
  {
109
+ isRunning = false;
108
110
  THROW_ERROR("RegisterNotification failed")
109
111
  }
110
112
  }
package/src/node_usb.cc CHANGED
@@ -141,9 +141,10 @@ Napi::Value EnableHotplugEvents(const Napi::CallbackInfo& info) {
141
141
  if (!instanceData->hotplugEnabled) {
142
142
  instanceData->hotplugThis.Reset(info.This().As<Napi::Object>(), 1);
143
143
 
144
+ // Start queue, then enable hotplug events
145
+ instanceData->hotplugQueue.start(env);
144
146
  instanceData->hotplugManager->enableHotplug(env, instanceData);
145
147
 
146
- instanceData->hotplugQueue.start(env);
147
148
  instanceData->hotplugEnabled = true;
148
149
  }
149
150
  return env.Undefined();
@@ -155,9 +156,11 @@ Napi::Value DisableHotplugEvents(const Napi::CallbackInfo& info) {
155
156
  ModuleData* instanceData = env.GetInstanceData<ModuleData>();
156
157
 
157
158
  if (instanceData->hotplugEnabled) {
158
- instanceData->hotplugManager->disableHotplug(env, instanceData);
159
159
 
160
+ // Disable events, then stop queue
161
+ instanceData->hotplugManager->disableHotplug(env, instanceData);
160
162
  instanceData->hotplugQueue.stop();
163
+
161
164
  instanceData->hotplugEnabled = false;
162
165
  }
163
166
  return env.Undefined();