Skip to content

router modified in place causing duplicate routes #992

@JosiahParry

Description

@JosiahParry

System details

Output of sessioninfo::session_info()():

─ Session info ─────────────────────────────────────────────────
 setting  value
 version  R Under development (unstable) (2025-02-08 r87709)
 os       macOS Sequoia 15.0.1
 system   aarch64, darwin20
 ui       X11
 language (EN)
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       America/Los_Angeles
 date     2025-03-09
 pandoc   3.2.1 @ /opt/homebrew/bin/ (via rmarkdown)
 quarto   1.6.40 @ /usr/local/bin/quarto

─ Packages ─────────────────────────────────────────────────────
 package     * version date (UTC) lib source
 callr         3.7.6   2024-03-25 [1] CRAN (R 4.5.0)
 cli           3.6.4   2025-02-13 [1] CRAN (R 4.5.0)
 clipr         0.8.0   2022-02-22 [1] CRAN (R 4.5.0)
 data.table    1.17.0  2025-02-22 [1] CRAN (R 4.5.0)
 digest        0.6.37  2024-08-19 [1] CRAN (R 4.5.0)
 evaluate      1.0.3   2025-01-10 [1] CRAN (R 4.5.0)
 fastmap       1.2.0   2024-05-15 [1] CRAN (R 4.5.0)
 fs            1.6.5   2024-10-30 [1] CRAN (R 4.5.0)
 glue          1.8.0   2024-09-30 [1] CRAN (R 4.5.0)
 htmltools     0.5.8.1 2024-04-04 [1] CRAN (R 4.5.0)
 knitr         1.49    2024-11-08 [1] CRAN (R 4.5.0)
 lifecycle     1.0.4   2023-11-07 [1] CRAN (R 4.5.0)
 magrittr      2.0.3   2022-03-30 [1] CRAN (R 4.5.0)
 pillar        1.10.1  2025-01-07 [1] CRAN (R 4.5.0)
 pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 4.5.0)
 processx      3.8.6   2025-02-21 [1] CRAN (R 4.5.0)
 ps            1.9.0   2025-02-18 [1] CRAN (R 4.5.0)
 R6            2.6.1   2025-02-15 [1] CRAN (R 4.5.0)
 reprex        2.1.1   2024-07-06 [1] CRAN (R 4.5.0)
 rlang         1.1.5   2025-01-17 [1] CRAN (R 4.5.0)
 rmarkdown     2.29    2024-11-04 [1] CRAN (R 4.5.0)
 rstudioapi    0.17.1  2024-10-22 [1] CRAN (R 4.5.0)
 sessioninfo   1.2.3   2025-02-05 [1] CRAN (R 4.5.0)
 tibble        3.2.1   2023-03-20 [1] CRAN (R 4.5.0)
 vctrs         0.6.5   2023-12-01 [1] CRAN (R 4.5.0)
 withr         3.0.2   2024-10-28 [1] CRAN (R 4.5.0)
 xfun          0.51    2025-02-19 [1] CRAN (R 4.5.0)
 yaml          2.3.10  2024-07-26 [1] CRAN (R 4.5.0)

 [1] /Users/josiahparry/Library/R/arm64/4.5/library
 [2] /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library

────────────────────────────────────────────────────────────────

Example application or steps to reproduce the problem

library(plumber)
pr <- pr() 
for (i in 1:5) {
  pr_get(pr, "/hi", function() "Hello World")
}

pr
#> # Plumber router with 5 endpoints, 4 filters, and 0 sub-routers.
#> # Use `pr_run()` on this object to start the API.
#> ├──[queryString]
#> ├──[body]
#> ├──[cookieParser]
#> ├──[sharedSecret]
#> └──/hi (GET, GET, GET, GET, GET)

Created on 2025-03-09 with reprex v2.1.1

Describe the problem in detail

Running a route handler multiple times on the same pr object, even without assignment, adds another endpoint.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions