usb 2.10.0 → 2.11.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.11.0] - 2023-10-02
4
+
5
+ ### Fixed
6
+ - Allow use of close on a closed device - [`676`](https://github.com/node-usb/node-usb/pull/676) ([Julien Vanier](https://github.com/monkbroc))
7
+
3
8
  ## [2.10.0] - 2023-08-22
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.10.0",
5
+ "version": "2.11.0",
6
6
  "main": "dist/index.js",
7
7
  "engines": {
8
8
  "node": ">=12.22.0 <13.0 || >=14.17.0"
Binary file
Binary file
Binary file
package/src/device.cc CHANGED
@@ -203,9 +203,11 @@ Napi::Value Device::Open(const Napi::CallbackInfo& info) {
203
203
  Napi::Value Device::Close(const Napi::CallbackInfo& info) {
204
204
  ENTER_METHOD(Device, 0);
205
205
  if (self->canClose()){
206
- libusb_close(self->device_handle);
207
- self->device_handle = NULL;
208
- completionQueue.stop();
206
+ if (self->device_handle){
207
+ libusb_close(self->device_handle);
208
+ self->device_handle = NULL;
209
+ completionQueue.stop();
210
+ }
209
211
  }else{
210
212
  THROW_ERROR("Can't close device with a pending request");
211
213
  }