-
-
Notifications
You must be signed in to change notification settings - Fork 625
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
Adapt to Cloudflare Workers environment #2289
base: master
Are you sure you want to change the base?
Conversation
6954a22
to
c4d5458
Compare
This PR can run on Cloudflare Workers with the following database:
@sidorares could you please approve to run the GitHub action? |
4760d37
to
0b9245b
Compare
@shiyuhang0 @Mini256 thanks for working on this! Could you document simple steps I can follow to try it myself? |
This commit adds a step-by-step tutorial. Since it's user-facing, it needs a new release of MySQL2 including this PR. |
3034a14
to
8949aca
Compare
8949aca
to
cc3458f
Compare
CI is green. Maybe we can ignore the failure of CodeQL action, because the error is reported in the code that originally existed (just the location has changed) As for the static parser. We'd like to merge your PR #2099 rather than cherry-pick it into this PR. What's your opinion? @sidorares |
I can probably merge it first, together with added binary protocol non-jit parser. re testing - thanks a lot for dev documentation. Are you aware of any way to test workers locally or in actions runtime? something similar to localstack. Ideally with the same checks, e.i errors when code tries to eval. Any container we can use for that? |
Cloudflare Workers provide an https://developers.cloudflare.com/workers/wrangler/api/#unstable_dev Test code in node-postgres: |
I prefer |
I like it more than |
I have tested this pr on multiple MySQL server ranging from old 5.7 to more recent MySQL and MariaDB version locally and on deployed workers so far it works flawlessly. The only issue is having to set |
FYI:
Otherwise, we'd love to see this merged + we're bringing MySQL support to Hyperdrive: https://developers.cloudflare.com/hyperdrive/ |
I have resolved the conflict with master branch. |
Hi, @shiyuhang0 🙋🏻♂️ If it's okay, I'd like to make a few simple suggestions in the documentation:
|
already doing this, will push a commit soon |
@shiyuhang0 what do you think about |
Both it is fine for me. But we shouldn't worry about modifying parameter names in an unmerged PR. For me, I think it can even be modified before release. I will adjust this PR after the name is determined |
I really need this feature. I need to use the node-mysql2 driver with Drizzle in Cloudflare Workers. If everything is confirmed to be correct, could you please merge this PR as soon as possible? Thanks |
@m430 last time I checked Drizzle/Mysql was not compatible with cloudflare even using this updated driver. That is because of some node compatibility issue. @shiyuhang0 disableEval makes more sense to me |
@shiyuhang0 missed your message, I also prefer |
@sidorares I have pushed a new commit to use |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2289 +/- ##
=========================================
Coverage ? 89.47%
=========================================
Files ? 76
Lines ? 16021
Branches ? 1363
=========================================
Hits ? 14334
Misses ? 1687
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Is there a path to instead supporting our modern https://developers.cloudflare.com/workers/runtime-apis/nodejs/ |
Just a note, while in the docs it says |
I forget push the change in code |
Does this PR works in his current state? Or do we have a list of the things that are missing to collaborate? |
Hi, everyone! I'd like to propose simplifying the process 🙋🏻♂️ Due to many responsibilities in a single PR, rebasing is necessary constantly, in addition to the difficulty of reviewing, I've tried to figure out the changes and the suggestion would be to create one refactoring at a time:
By breaking down responsibilities, it's easier both to review and to prevent the constant need to rebase commits. |
@wellwelwel Yes, we can discuss this in PR #2099 (or another dedicated PR) and use it as a precursor PR to support the new non-eval parser in mysql2, avoiding this PR from handling too many tasks. After that, we can rebase this PR. |
try to close #2179
Summary
window is not found
, replace nodeTimers
with web timersCode generation from strings disallowed for this context
, using the static parser in PR Add "interpreting" parser #2099crypto.hash() is not a function
, polyfill nodecrypto
withwebcrypto
, and modify the functions which directly/indirectly called thecrypto
library as async function.TODOs:
pg-cloudflare
withmysql2-cloudflare
?Usage
For users, they need to:
node_compat = true
flag to polyfill the missing node modulesuseStaticParser
flag to force mysql2 to use static parser.For example: https://github.com/Mini256/mysql2-cloudflare-test/blob/1f339a85f4457b696f122503051991326dbc23dc/src/index.ts#L30