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

chore: update axum to 0.8 #302

Closed
wants to merge 2 commits into from
Closed

Conversation

getong
Copy link

@getong getong commented Jan 13, 2025

Context & Description

update axum to 0.8

@getong getong requested a review from Valerioageno as a code owner January 13, 2025 03:24
@getong getong force-pushed the update-axum-0.8 branch 2 times, most recently from 158de91 to 751f66f Compare January 13, 2025 09:22
@github-actions github-actions bot added the rust Requires rust knowledge label Jan 13, 2025
@Valerioageno
Copy link
Member

Hey! Thanks for tackling this!
Apparently, axum v0.8 changed the way they handle the * wildcard operator. See error:
Screenshot 2025-01-13 183207

Do you mind fix also this?

@getong
Copy link
Author

getong commented Jan 14, 2025

Hey! Thanks for tackling this! Apparently, axum v0.8 changed the way they handle the * wildcard operator. See error: Screenshot 2025-01-13 183207

Do you mind fix also this?

This is done.

How do you run into this error? I just run cargo build

@Valerioageno
Copy link
Member

cargo build just tests that the project compiles.
If you then set an alias to the binary path alias t="/path-to-repo/target/debug/tuono" you can use it as if it is installed.

Then you can just create a new project with t new and run it in development mode with t dev

@getong
Copy link
Author

getong commented Jan 14, 2025

I new a tuono project with target/debug/tuono, and target/debug/tuono dev , it works.

Need anything else?

@Valerioageno
Copy link
Member

If you try to run t dev within tuono/examples/tuono-app what is the outcome?

@getong
Copy link
Author

getong commented Jan 14, 2025

If you try to run t dev within tuono/examples/tuono-app what is the outcome?

$ pnpm i

$ ../../target/debug/tuono dev  
node:internal/errors:496
    ErrorCaptureStackTrace(err);
    ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/a/test/rust/tuono/packages/tuono/dist/esm/build/index.js' imported from /Users/a/test/rust/tuono/packages/tuono/bin/watch.js
    at new NodeError (node:internal/errors:405:5)
    at finalizeResolution (node:internal/modules/esm/resolve:327:11)
    at moduleResolve (node:internal/modules/esm/resolve:980:10)
    at defaultResolve (node:internal/modules/esm/resolve:1206:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:404:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:373:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:250:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:39)
    at link (node:internal/modules/esm/module_job:75:36) {
  url: 'file:///Users/a/test/rust/tuono/packages/tuono/dist/esm/build/index.js',
  code: 'ERR_MODULE_NOT_FOUND'
}

Node.js v18.20.5
node:internal/errors:496
    ErrorCaptureStackTrace(err);
    ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/a/test/rust/tuono/packages/tuono/dist/esm/build/index.js' imported from /Users/a/test/rust/tuono/packages/tuono/bin/dev-ssr.js
    at new NodeError (node:internal/errors:405:5)
    at finalizeResolution (node:internal/modules/esm/resolve:327:11)
    at moduleResolve (node:internal/modules/esm/resolve:980:10)
    at defaultResolve (node:internal/modules/esm/resolve:1206:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:404:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:373:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:250:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:39)
    at link (node:internal/modules/esm/module_job:75:36) {
  url: 'file:///Users/a/test/rust/tuono/packages/tuono/dist/esm/build/index.js',
  code: 'ERR_MODULE_NOT_FOUND'
}

Node.js v18.20.5

thread 'tokio-runtime-worker' panicked at /Users/a/.cargo/registry/src/rsproxy.cn-e3de039b2554c837/watchexec-supervisor-3.0.0/src/job/task.rs:54:17:
all branches are disabled and there is no else branch
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@Valerioageno
Copy link
Member

You first have to run pnpm i && pnpm build in the root folder

@getong
Copy link
Author

getong commented Jan 14, 2025

$ pnpm i && pnpm build
Scope: all 9 workspace projects
Done in 806ms
 ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL  Command failed with EACCES: build
spawn build EACCES

@getong
Copy link
Author

getong commented Jan 14, 2025

$ ../../target/debug/tuono dev                                    
17:04:43 [12/1507]node:internal/errors:496
    ErrorCaptureStackTrace(err);                                                                                         ^                                                                                                                
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/a/test/rust/tuono/packages/tuono/dist/esm/build/index.js' imported from /Users/a/test/rust/tuono/packages/tuono/bin/watch.js                             
    at new NodeError (node:internal/errors:405:5)
    at finalizeResolution (node:internal/modules/esm/resolve:327:11)                                 
    at moduleResolve (node:internal/modules/esm/resolve:980:10)                              
    at defaultResolve (node:internal/modules/esm/resolve:1206:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:404:12)                         
    at ModuleLoader.resolve (node:internal/modules/esm/loader:373:25)                        
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:250:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:39)
    at link (node:internal/modules/esm/module_job:75:36) {
  url: 'file:///Users/a/test/rust/tuono/packages/tuono/dist/esm/build/index.js',
  code: 'ERR_MODULE_NOT_FOUND'
}

Node.js v18.20.5

thread 'tokio-runtime-worker' panicked at /Users/a/.cargo/registry/src/rsproxy.cn-e3de039b2554c837/watchexec-supervisor-3.0.0/src/job/task.rs:54:17:
all branches are disabled and there is no else branch
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
node:internal/errors:496
    ErrorCaptureStackTrace(err);
    ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/a/test/rust/tuono/packages/tuono/dist/esm/build/index.js' imported from /Users/a/test/rust/tuono/packages/tuono/bin/dev-ssr.js
    at new NodeError (node:internal/errors:405:5)
    at finalizeResolution (node:internal/modules/esm/resolve:327:11)
    at moduleResolve (node:internal/modules/esm/resolve:980:10)
    at defaultResolve (node:internal/modules/esm/resolve:1206:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:404:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:373:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:250:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:39)
    at link (node:internal/modules/esm/module_job:75:36) {
  url: 'file:///Users/a/test/rust/tuono/packages/tuono/dist/esm/build/index.js',
  code: 'ERR_MODULE_NOT_FOUND'
}

Node.js v18.20.5

  ⚡ Tuono v0.17.0
  Ready at: http://localhost:3000


thread 'tokio-runtime-worker' panicked at /Users/a/test/rust/tuono/crates/tuono_lib/src/ssr.rs:51:60:
Server bundle not found: Os { code: 2, kind: NotFound, message: "No such file or directory" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@Valerioageno
Copy link
Member

There is some problem with the way you install then build the JS dependencies. The error you just posted means that the dependencies are not built

@getong
Copy link
Author

getong commented Jan 14, 2025

finally, I make it works

$ cd tuono
$ pnpm i & pnpm build
$ cargo build
$ cd  examples/tuono-app
$ pnpm i
$ ../../target/debug/tuono dev

  ⚡ Tuono v0.17.0
  Ready at: http://localhost:3000

  GET / 200 in 43ms
  GET / 200 in 40ms

@Valerioageno
Copy link
Member

Nice. I'll test on my side later! When I tested it yesterday, I got the above error!

@Valerioageno
Copy link
Member

Yeah, I got the same error.
Watching at their documentation, they changed the routing works https://docs.rs/axum/latest/axum/#routing.
That said, we need first to implement integration tests for tuono_lib in order to avoid to break the production apps.

Would you be interested of adding such tests before moving forward?

@getong
Copy link
Author

getong commented Jan 15, 2025

Yeah, I got the same error. Watching at their documentation, they changed the routing works https://docs.rs/axum/latest/axum/#routing. That said, we need first to implement integration tests for tuono_lib in order to avoid to break the production apps.

Would you be interested of adding such tests before moving forward?

// axum 0.7, react [single] maps to :single, [...many] maps to *many,
// axum 0.8, the path parameter syntax from /:single and /*many to /{single} and /{*many}
// so axum 0.8, react [single] maps to {single}, [...many] maps to {*many}

I think the code mapping is okay now, need feedback

@getong getong force-pushed the update-axum-0.8 branch 2 times, most recently from a9dcc91 to c6f62f0 Compare January 15, 2025 15:27
@Valerioageno
Copy link
Member

Too risky to move forward without proper integration tests. Let me know if you are interested about implementing them

@getong
Copy link
Author

getong commented Jan 16, 2025

Too risky to move forward without proper integration tests. Let me know if you are interested about implementing them

I am not familiar with react code, I run the cargo test in the crates/tuono, the result is okay.
If you need more compicated test, I need instruction, I need to know how to write it, might be a week of time.
Chinese New Year is coming, busy with something others.

@Valerioageno
Copy link
Member

No worries! Take your time.

The goal would be to find a way to check that tuono_lib correctly compiles a server.
I'd do it by adding tests in crates/tuono_lib/tests/ and finding a way to mock a tuono project directory.

Unfortunately, I don't have enough time to train about the codebase. This would require a proper investigation and for now is not prioritized in my schedule (here the issue)!

I'm closing this PR for now. Feel free to reopen it after the implemented test coverage!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rust Requires rust knowledge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants