tigrisdata-archive / tigris-client-ts

TypeScript client for Tigris
https://www.tigrisdata.com/docs/sdkstools/typescript/
Apache License 2.0
15 stars 10 forks source link

Validate that the Tigris TypeScript library works in Cloudflare workers #368

Closed ovaistariq closed 1 year ago

ovaistariq commented 1 year ago

Cloudflare workers have support for node.js. We need to build an app on Cloudflare workers that uses Tigris and verify that Tigris TypeScript works perfectly. If any problems are found, let's create GitHub issues for them.

ovaistariq commented 1 year ago

/bounty $25

algora-pbc[bot] commented 1 year ago

💎 $25 bounty created by ovaistariq 🙋 If you start working on this, comment /attempt #368 to notify everyone 👉 To claim this bounty, submit a pull request that includes the text /claim #368 somewhere in its body 📝 Before proceeding, please make sure you can receive payouts in your country 💵 Payment arrives in your account 2-5 days after the bounty is rewarded 💯 You keep 100% of the bounty award 🙏 Thank you for contributing to tigrisdata/tigris-client-ts!

tachyonicbytes commented 1 year ago

/attempt #368

Hi! I would love to work on this!

I have one question about the deliverable here. Where would the test app be commited? Should it be in src/_tests_/tigris.worker.spec.ts?

ovaistariq commented 1 year ago

Yes, let's start with that. If it turns out that it needs its own repo, we can do that. BTW, I found this nice post about unit testing code with cloudflare workers: https://blog.cloudflare.com/unit-testing-workers-in-cloudflare-workers/

tachyonicbytes commented 1 year ago

So, for a status:

There may be a blocker: Cloudflare has disabled the unsafe-eval property for cloudflare workers, and openapi generates unsafe evals, at least for tigris-api/server/v1/api.proto.

Some code examples seem to indicate that this is bypassable, so I will continue to investigate.

Things that remain to be done:

ovaistariq commented 1 year ago

Thanks for the update @tachyonicbytes. Definitely, seems better to have a separate repo. Since this will be a separate repo, let's approach this as an example app that runs on cloudflare worker and uses Tigris. What do you think?

tachyonicbytes commented 1 year ago

That seems right. Do you think it fits in https://github.com/tigrisdata/tigris-examples-ts, or should it be a separate repo in the tigris organization? Something like https://github.com/tigrisdata/tigris-example-cloudflare?

As for the code itself, do you think my approach is right for now? I mean getting the code from the documentation to run

tachyonicbytes commented 1 year ago

I'm still searching the internet for directions in order to solve that problem. It seems that this aws library migrated from new Function, in order to side-step this exact bug. The recommendation from this cloudflare community answer seems to be that there is currently no way to side-step it, apart from not using new Function anymore.