Skip to content

Trying to use with PGlite (wasm Postgres) and getting: Error generating modules: Could not read 'valtype', unexpected byte: b, expected one of... #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
3 tasks done
samwillis opened this issue Apr 22, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@samwillis
Copy link

Before submitting a new issue

  • I tested using the latest version of the library, as the bug might be already fixed.
  • I tested using a supported version of react native.
  • I checked for possible duplicate issues, with possible answers.

Bug summary

Hey,

I'm one of the developers working on PGlite, a WASM build of Postgres. Polygen looks super cool! I'm very excited to try PGlite with it. We have been looking at various routes to React Native support, and Polygen look like it could be a perfect fit. We have done some experiments with wasm2c and have validated that we can run a PGlite build thats been decompiled to C with it.

However, when I run npx polygen generate I am seeing this error:

npx polygen generate
ℹ Generating code for 1 WebAssembly module(s)                                   16:51:55
✖ Processing local module ./assets/postgres.wasm

[16:51:55]  ERROR  Error generating modules: Could not read 'valtype', unexpected byte: b, expected one of [127, 126, 125, 124, 123, 112, 111] (binary offset: 0x40f4)

We tried it with both an Emscripten build, and one produces by the WASI SDK and get a similar result.

The WASI build of PGlite (which we event officially released yet) does decompile with wasm2c - we've tried that route ourselves.

These are the two files:

Emscripten build: postgres.wasm.zip

WASI SDK build: pglite.wasi.zip

Please let me know if there is anything I can do to help debug this.

Library version

0.2.1

Environment info

expo-env-info 1.2.2 environment info:
    System:
      OS: macOS 15.3.2
      Shell: 5.9 - /bin/zsh
    Binaries:
      Node: 23.11.0 - ~/.nvm/versions/node/v23.11.0/bin/node
      npm: 10.9.2 - ~/.nvm/versions/node/v23.11.0/bin/npm
    Managers:
      CocoaPods: 1.16.2 - /opt/homebrew/bin/pod
    SDKs:
      iOS SDK:
        Platforms: DriverKit 24.2, iOS 18.2, macOS 15.2, tvOS 18.2, visionOS 2.2, watchOS 11.2
    IDEs:
      Android Studio: 2022.3 AI-223.8836.35.2231.10671973
      Xcode: 16.2/16C5032a - /usr/bin/xcodebuild
    npmPackages:
      expo: ~52.0.46 => 52.0.46 
      expo-router: ~4.0.20 => 4.0.20 
      react: 18.3.1 => 18.3.1 
      react-dom: 18.3.1 => 18.3.1 
      react-native: 0.76.9 => 0.76.9 
      react-native-web: ~0.19.13 => 0.19.13 
    Expo Workflow: managed

Steps to reproduce

Download the files above, put them in a project with polygon, and try to run generate against them.

Reproducible sample code

export default polygenConfig({
  /...... snip
  /**
   * List of modules to be used in the project.
   *
   * Each module can be individually configured, by passing options object as a second
   * argument (or 3rd, for external modules).
   */
  modules: [
    localModule('./assets/postgres.wasm'),
    // localModule('./assets/pglite.wasi'),
  ],
});
@samwillis samwillis added the bug Something isn't working label Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant