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

Toast provider not included in production builds when used with sync events #4845

Open
clemlesne opened this issue Feb 19, 2025 · 2 comments

Comments

@clemlesne
Copy link

Describe the bug

When toasts are included in sync events, build error appears only in prod mode.

To reproduce

VERSION = "v0.0.0"

# ...

rx.text(
    f"v{VERSION} ({rx.config.environment.REFLEX_ENV_MODE.get().value})",
    on_mouse_up=rx.set_clipboard(
        f"v{VERSION}"
    ),  # On Safari, async func are not allowed to access clipboard (see: https://github.com/reflex-dev/reflex/issues/4757#issue-2832833845)
    on_click=lambda: rx.toast.success(
        "Version copied to clipboard"
    ),
)

Expected behavior

App builds.

Logs

Builds logs without rx.toast.provider():

File "/[root]/app/pages/template.py", line 140, in _wrapper
  rx.text(
  ~~~~~~~^
      f"v{VERSION} ({rx.config.environment.REFLEX_ENV_MODE.get().value})",
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ...<7 lines>...
      size="1",
      ^^^^^^^^^
  ),
  ^
File "/[root]/.venv/lib/python3.13/site-packages/reflex/components/radix/themes/base.py", line 139, in create
  component = super().create(*children, **props)
File "/[root]/.venv/lib/python3.13/site-packages/reflex/components/component.py", line 736, in create
  return cls(children=children, **props)
File "/[root]/.venv/lib/python3.13/site-packages/reflex/components/component.py", line 491, in __init__
  kwargs["event_triggers"][key] = EventChain.create(
                                  ~~~~~~~~~~~~~~~~~^
      value=value,
      ^^^^^^^^^^^^
      args_spec=component_specific_triggers[key],
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      key=key,
      ^^^^^^^^
  )
  ^
File "/[root]/.venv/lib/python3.13/site-packages/reflex/event.py", line 484, in create
  result = call_event_fn(value, args_spec, key=key)
File "/[root]/.venv/lib/python3.13/site-packages/reflex/event.py", line 1494, in call_event_fn
  out = fn(*[*parsed_args][:number_of_fn_args])
File "/[root]/app/pages/template.py", line 146, in <lambda>
  on_click=lambda: rx.toast.success(
                    ~~~~~~~~~~~~~~~~^
      "Version copied to clipboard"
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ),
  ^
File "/[root]/.venv/lib/python3.13/site-packages/reflex/components/sonner/toast.py", line 328, in toast_success
  return Toaster.send_toast(message, level="success", **kwargs)
          ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/[root]/.venv/lib/python3.13/site-packages/reflex/components/sonner/toast.py", line 256, in send_toast
  raise ValueError(
      "Toaster component must be created before sending a toast. (use `rx.toast.provider()`)"
  )
ValueError: Toaster component must be created before sending a toast. (use `rx.toast.provider()`)

Builds logs with rx.toast.provider():

Creating Production Build failed with exit code 1

> export-sitemap
> next build && next-sitemap

   ▲ Next.js 15.1.6

   Linting and checking validity of types ...
   Creating an optimized production build ...
 ✓ Compiled successfully
   Collecting page data ...
   Generating static pages (0/8) ...
ReferenceError: useEffect is not defined
    at E (.next/server/pages/demo//review/edit.js:1:8700)
ReferenceError: useEffect is not defined
    at y (.next/server/pages/user.js:1:2006)
Error occurred prerendering page "/demo//review/edit". Read more: 
https://nextjs.org/docs/messages/prerender-error
ReferenceError: useEffect is not defined
[...]
Error occurred prerendering page "/user". Read more: 
https://nextjs.org/docs/messages/prerender-error
ReferenceError: useEffect is not defined
[...]
Export encountered an error on /demo//review/edit, exiting the build.
 ⨯ Static worker exited with code: 1 and signal: null

Specifics (please complete the following information)

  • Python version: 3.13
  • Reflex Version: 0.7.0
  • OS: macOS 15.3 (24D60) plus Ubuntu 24.04
Copy link

linear bot commented Feb 19, 2025

@adhami3310
Copy link
Member

can you test it with latest release of reflex?

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

No branches or pull requests

2 participants