@google-cloud/bigquery errors
Hi folks,
Whenever I install the @google-cloud/bigquery package I get errors on deployment. Is there something different I should be doing or a reason it doesn't work? Sorry I'm a novice developer.
![No description](https://cdn.answeroverflow.com/1200496977142632478/index.js_lf-bigquery_2024-01-26_at_10.44.04_AM.jpg)
16 Replies
Workers are not node. They run on Chrome's Javascript Engine v8, so they have a web like environment. You can enable node_compat and get some polyfills, but if it absolutely depends on a file system existing it's just not going to work
If I enable node_compat I get this. Does that look expected?
![No description](https://cdn.answeroverflow.com/1200497803097559070/wrangler.toml_lf-bigquery_2024-01-26_at_10.49.21_AM.jpg)
Thank you for the help @Chaika 🙂 Really appreciate it!
expected in the sense Workers don't support xmlhttprequest, some libraries offer a way to override it and make it use fetch, hmm
I guess I'm just wondering "is there a way to make it work" or it's just a "nope"
It's open source, there is always a way, but not necessarily easy or feasible
looks like it depends on gaxios which depends on node-fetch
Thank you so much for checking!
For someone who wouldn't know where to go next, what would you tell them to go look at next? 😂
hmm, what are you trying to do with bigquery? Just run queries?
I would like to send a webhook from my application to a worker, and then the worker would insert the row(s) into bigquery
Looks like it's been done before: https://github.com/defog-ai/cloud-workers-bigquery-ingest/tree/main
GitHub
GitHub - defog-ai/cloud-workers-bigquery-ingest: Cloudflare workers...
Cloudflare workers function to clean and ingest data before putting it into BigQuery - GitHub - defog-ai/cloud-workers-bigquery-ingest: Cloudflare workers function to clean and ingest data before p...
He's just using the api directly, I assume he couldn't get the lib working either. you probably could if you modified it a bit more, looks like gaxios can use fetch but only if the window and some other stuff exists, not build for serverless runtime.
Amazing! Thank you so much! I’ll check it out! Is it okay to replay in this thread if I have another question?
of course, yea it's a bit older but CF Workers guarantee compatibility based on the compat date
It looks like he's used the same library... curious how that works
![No description](https://cdn.answeroverflow.com/1200505547783413870/cloud-workers-bigquery-ingestpackage.json_at_main_defog-aicloud-workers-bigquery-ingest_2024-01-26_at_11.19.59_AM.jpg)
In the code he didn't, so it would just be ignored/not bundled
I didn't notice that before that's funny lol, I'm guessing he did try it. His code just uses the REST API directly