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

Serverside Rendering on Vercel fails; missing GLIBC_2.29 #15

Open
2 tasks done
ItsMeBrianD opened this issue Apr 14, 2023 · 10 comments
Open
2 tasks done

Serverside Rendering on Vercel fails; missing GLIBC_2.29 #15

ItsMeBrianD opened this issue Apr 14, 2023 · 10 comments

Comments

@ItsMeBrianD
Copy link

ItsMeBrianD commented Apr 14, 2023

What happens?

When attempting to deploy some Javascript project to Vercel that leverages SSR and DuckDB; the build fails.

The error message being presented by DuckDB is /lib64/libm.so.6: version 'GLIBC_2.29' not found (required by /vercel/path0/node_modules/duckdb/lib/binding/duckdb.node.

This has worked previously.

To Reproduce

This repo has a simple reproduction of the issue; simply create a vercel project based on this (or a fork), and the build will fail with the error message
https://github.com/ItsMeBrianD/duckdb-vercel-repro

OS:

Vercel

DuckDB Version:

0.7.1

DuckDB Client:

node

Full Name:

Brian Donald

Affiliation:

Evidence

Have you tried this on the latest master branch?

  • I agree

Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?

  • I agree
@archiewood
Copy link

@Mause we're using the NodeJS client - we're not sure, but perhaps this is new in 0.7.1?

@Mause
Copy link
Member

Mause commented Apr 15, 2023

@Mause we're using the NodeJS client - we're not sure, but perhaps this is new in 0.7.1?

Which version does it work with? We can check for changes

@tobilg
Copy link

tobilg commented Apr 17, 2023

As Vercel is running on AWS Lambda as far as I know, I'm having a hard time imagining that this has worked before, as Lambda environments are currently based on Amazon Linux 2, which uses GLIBC 2.26. See https://repost.aws/questions/QUrXOioL46RcCnFGyELJWKLw/glibc-2-27-on-amazon-linux-2

I guess you could download my DuckDB for Lambda layer, and extract the build artifacts: https://github.com/tobilg/duckdb-nodejs-layer#arns

@pgzmnk
Copy link

pgzmnk commented Jul 24, 2023

Experiencing similar error on Vercel with both node 18.x and 16.x.

https://github.com/pgzmnk/openb

image

@tobilg
Copy link

tobilg commented Sep 27, 2023

I therefor created https://www.npmjs.com/package/duckdb-lambda-x86 which should solve the actual issue.

@Mause
Copy link
Member

Mause commented Oct 17, 2023

@Mause we're using the NodeJS client - we're not sure, but perhaps this is new in 0.7.1?

Which version does it work with? We can check for changes

@archiewood any updates?

@hanshino
Copy link

I've encountered the same problem as described. Specifically, I'm using duckdb@0.7.1.

Environment:

  • Operating System: Ubuntu 22.02 and Mac M1 Sonoma
  • Encountered inside a Docker container
  • Docker Base Image: node:14

Steps to Reproduce:

docker run --rm -it node:14 bash

In node:14 container

mkdir app && cd app
yarn init -y
yarn add duckdb@0.7.1
cd node_modules/duckdb
npm test

Are there any necessary packages that I need to install?

Tranlated by ChatGPT.


Sorry for my english is not good. I hope there's no offense.

@tobilg
Copy link

tobilg commented Oct 21, 2023

@hanshino the default duckdb npm package will not work IMO due to GLIBC incompatibilities, as described above. For Lambda usage, I maintain the https://www.npmjs.com/package/duckdb-lambda-x86 package which should fix your issues.

@ryan-williams
Copy link

ryan-williams commented Nov 17, 2023

Here's a wrapper over duckdb-async and duckdb-lambda-x86 that I just wrote, which seems to work both on my M1 macbook (which requires duckdb-async) and on an EC2 instance where I was previously hitting the GLIBC_2.29 error (where duckdb-lambda-x86 works instead):

// lib/duckdb.ts
let _query: Promise<(query: string) => any>

_query = import("duckdb-async")
    .then(duckdb => duckdb.Database)
    .then(Database => Database.create(":memory:"))
    .then((db: any) => ((query: string) => db.all(query)))
    .catch(async error => {
        console.log("duckdb init error:", error)
        let duckdb = await import("duckdb-lambda-x86");
        let Database: any = await duckdb.Database;
        const db = new Database(":memory:")
        const connection = db.connect()
        return (query: string) => {
            return new Promise((resolve, reject) => {
                connection.all(query, (err: any, res: any) => {
                    if (err) reject(err);
                    resolve(res);
                })
            })
        }
    })

export { _query }

Sample API endpoint that uses it:

// /api/query.ts
import { _query } from "@/lib/duckdb"
import { NextApiRequest, NextApiResponse } from "next";

// Convert BigInts to numbers
function replacer(key: string, value: any) {
    if (typeof value === 'bigint') {
        return Number(value)
    } else {
        return value;
    }
}

export default async function handler(
    req: NextApiRequest,
    res: NextApiResponse,
) {
    const { body: { path } } = req
    const query = await _query
    const rows = await query(`select * from read_parquet("${path}")`)  // 🚨 unsafe / SQLi 🚨
    res.status(200).send(JSON.stringify(rows, replacer))
}

@michaelwallabi
Copy link

FYI for others who run into this. I ended up using @tobilg's duckdb-lambda-x86 to resolve this with Vercel. In my case I'm just replacing the default duckdb.node binary with the duckdb-lambda-x86 version in the CI build.

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

No branches or pull requests

8 participants