mrousavy / nitro

🔥 Insanely fast native C++, Swift or Kotlin modules with a statically compiled binding layer to JSI
https://nitro.margelo.com
MIT License
642 stars 22 forks source link

Promise<ArrayBuffer> breaks on iOS #329

Closed grabbou closed 1 week ago

grabbou commented 1 week ago

What's happening?

Reproduceable Code

Typescript:

type A : HybridObject<{ iOS: "swift" }> {
  callMe(): Promise<ArrayBuffer>
}

Cpp
```cpp
  // Methods
  @inline(__always)
  public func read() -> bridge.PromiseHolder_std__shared_ptr_ArrayBuffer__ {
    do {
      let __result = try self.__implementation.read()
      return { () -> bridge.PromiseHolder_std__shared_ptr_ArrayBuffer__ in
        let __promiseHolder = bridge.create_PromiseHolder_std__shared_ptr_ArrayBuffer__()
        __result
          .then({ __result in __promiseHolder.resolve(__result) })
          .catch({ __error in __promiseHolder.reject(std.string(String(describing: __error))) })
        return __promiseHolder
      }()
    } catch {
      let __message = "\(error.localizedDescription)"
      fatalError("Swift errors can currently not be propagated to C++! See https://github.com/swiftlang/swift/issues/75290 (Error: \(__message))")
    }
  }

### Relevant log output

```shell
> Cannot convert value of type 'ArrayBufferHolder' (aka 'margelo.nitro.ArrayBufferHolder') to expected argument type 'std.__1.shared_ptr<ArrayBuffer>'

Device

Any

Nitro Modules Version

0.15.0

Nitrogen Version

0.15.0

Can you reproduce this issue in the Nitro Example app here?

I didn't try (⚠️ your issue might get ignored & closed if you don't try this)

Additional information

grabbou commented 1 week ago

Here's a quick-fix in source

CleanShot 2024-11-13 at 12 26 32@2x

mrousavy commented 1 week ago

fix: https://github.com/mrousavy/nitro/pull/330

mrousavy commented 1 week ago

Released in 0.16.2