@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
16 Replies
Chaika
Chaika•10mo ago
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
Stockton
StocktonOP•10mo ago
If I enable node_compat I get this. Does that look expected?
No description
Stockton
StocktonOP•10mo ago
Thank you for the help @Chaika 🙂 Really appreciate it!
Chaika
Chaika•10mo ago
expected in the sense Workers don't support xmlhttprequest, some libraries offer a way to override it and make it use fetch, hmm
Stockton
StocktonOP•10mo ago
I guess I'm just wondering "is there a way to make it work" or it's just a "nope"
Chaika
Chaika•10mo ago
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
Stockton
StocktonOP•10mo ago
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? 😂
Chaika
Chaika•10mo ago
hmm, what are you trying to do with bigquery? Just run queries?
Stockton
StocktonOP•10mo ago
I would like to send a webhook from my application to a worker, and then the worker would insert the row(s) into bigquery
Chaika
Chaika•10mo ago
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...
Chaika
Chaika•10mo ago
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.
Stockton
StocktonOP•10mo ago
Amazing! Thank you so much! I’ll check it out! Is it okay to replay in this thread if I have another question?
Chaika
Chaika•10mo ago
of course, yea it's a bit older but CF Workers guarantee compatibility based on the compat date
Stockton
StocktonOP•10mo ago
It looks like he's used the same library... curious how that works
No description
Chaika
Chaika•10mo ago
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
Stockton
StocktonOP•10mo ago
ahh got it. Okay, going to keep exploring this 🙂 This is working! Thank you so much! 🙂
Want results from more Discord servers?
Add your server