Skip to content
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

Can't install and load spatial extension #1542

Closed
nshiab opened this issue Dec 18, 2023 · 9 comments · Fixed by #1544
Closed

Can't install and load spatial extension #1542

nshiab opened this issue Dec 18, 2023 · 9 comments · Fixed by #1544
Assignees

Comments

@nshiab
Copy link

nshiab commented Dec 18, 2023

What happens?

When trying to reproduce the example from Extension for DuckDB-Wasm, I couldn't install and load the spatial extension.

Here's the error:

async_bindings.ts:150 Uncaught Error: IO Error: Extension "/home/web_user/.duckdb/extensions/v0.9.1/wasm_eh/spatial.duckdb_extension" not found.
Extension "spatial" is an existing extension.

Install it first using "INSTALL spatial".

To Reproduce

Here's the code I used. You can copy and paste it into an HTML file and open it with a browser.

<!DOCTYPE html>
<html>
  <body>
    <script type="module">
      import * as duckdb from "https://cdn.jsdelivr.net/npm/@duckdb/duckdb-wasm@1.28.0/+esm";

      const JSDELIVR_BUNDLES = duckdb.getJsDelivrBundles();

      // Select a bundle based on browser checks
      const bundle = await duckdb.selectBundle(JSDELIVR_BUNDLES);

      const worker_url = URL.createObjectURL(
        new Blob([`importScripts("${bundle.mainWorker}");`], {
          type: "text/javascript",
        })
      );

      // Instantiate the asynchronus version of DuckDB-wasm
      const worker = new Worker(worker_url);
      const logger = new duckdb.ConsoleLogger();
      const db = new duckdb.AsyncDuckDB(logger, worker);
      await db.instantiate(bundle.mainModule, bundle.pthreadWorker);
      URL.revokeObjectURL(worker_url);

      const conn = await db.connect();
      await conn.query(`INSTALL spatial; LOAD spatial;`);
    </script>
  </body>
</html>

Browser/Environment:

Version 120.0.6099.109 (Official Build) (arm64)

Device:

MacBoork PRO m1

DuckDB-Wasm Version:

1.28.0

DuckDB-Wasm Deployment:

html page

Full Name:

Nael Shiab

Affiliation:

CBC/Radio-Canada

@domoritz
Copy link
Collaborator

The shell is using @duckdb/duckdb-wasm@1.28.1-dev59.0. Extension support is pretty new so try the latest version.

@carlopi carlopi self-assigned this Dec 19, 2023
@nshiab
Copy link
Author

nshiab commented Dec 19, 2023

Thanks, @domoritz ! But it doesn't look like it's available on npm for now. I guess I am too impatient! It's a great addition to be able to use extensions. :)

https://www.npmjs.com/package/@duckdb/duckdb-wasm?activeTab=versions

@carlopi
Copy link
Collaborator

carlopi commented Dec 21, 2023

I need to review why CI had not pushed a new version on npm, I will update when it's out.

@carlopi
Copy link
Collaborator

carlopi commented Dec 29, 2023

Can you give it a try with the latest package on npm: 1.28.1-dev65.0?

It should work while hosting it locally.

Edit: adding some details, it will not work out of the box just changing the line above since jsdelivr has not (yet?) hosted the proper resources, but it should be doable if you host them together with the index.html that you have.

@nshiab
Copy link
Author

nshiab commented Jan 3, 2024

Hi!

So...

I guess something went wrong when publishing on npm...

@tobilg
Copy link

tobilg commented Jan 4, 2024

I checked this on npm as well, 1.28.0 is 71.9 MB (https://www.npmjs.com/package/@duckdb/duckdb-wasm/v/1.28.0), 1.28.1-dev65.0 is 1.63 GB which is more than 20 times as much.

Seems like this can't be correct even with more exposed functions...

@carlopi
Copy link
Collaborator

carlopi commented Jan 18, 2024

I think this should be solved, jsdelivr is back online: https://www.jsdelivr.com/package/npm/@duckdb/duckdb-wasm.

Serving this file works now as intended (no errors shown):

<!DOCTYPE html>
<html>
  <body>
    <script type="module">
      import * as duckdb from "https://cdn.jsdelivr.net/npm/@duckdb/duckdb-wasm@1.28.1-dev91.0/+esm";

      const JSDELIVR_BUNDLES = duckdb.getJsDelivrBundles();

      // Select a bundle based on browser checks
      const bundle = await duckdb.selectBundle(JSDELIVR_BUNDLES);

      const worker_url = URL.createObjectURL(
        new Blob([`importScripts("${bundle.mainWorker}");`], {
          type: "text/javascript",
        })
      );

      // Instantiate the asynchronus version of DuckDB-wasm
      const worker = new Worker(worker_url);
      const logger = new duckdb.ConsoleLogger();
      const db = new duckdb.AsyncDuckDB(logger, worker);
      await db.instantiate(bundle.mainModule, bundle.pthreadWorker);
      URL.revokeObjectURL(worker_url);

      const conn = await db.connect();
      await conn.query(`INSTALL spatial; LOAD spatial;`);
    </script>
  </body>
</html>

@carlopi carlopi closed this as completed Jan 18, 2024
@carlopi
Copy link
Collaborator

carlopi commented Jan 18, 2024

Thanks for the patience, and see the discussion here: #1561 for more background informations.

@nshiab
Copy link
Author

nshiab commented Jan 18, 2024

Wonderful! Thanks, @carlopi!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants