Просмотр исходного кода

expose staticPageGenerationTimeout (#4266)

* expose staticPageGenerationTimeout

* update tests
Khaleel Al-Adhami 6 месяцев назад
Родитель
Сommit
d478387007
3 измененных файлов с 17 добавлено и 5 удалено
  1. 3 0
      reflex/config.py
  2. 1 0
      reflex/utils/prerequisites.py
  3. 13 5
      tests/units/test_prerequisites.py

+ 3 - 0
reflex/config.py

@@ -451,6 +451,9 @@ class Config(Base):
     # The bun path
     bun_path: ExistingPath = constants.Bun.DEFAULT_PATH
 
+    # Timeout to do a production build of a frontend page.
+    static_page_generation_timeout: int = 60
+
     # List of origins that are allowed to connect to the backend API.
     cors_allowed_origins: List[str] = ["*"]
 

+ 1 - 0
reflex/utils/prerequisites.py

@@ -677,6 +677,7 @@ def _update_next_config(
         "compress": config.next_compression,
         "reactStrictMode": config.react_strict_mode,
         "trailingSlash": True,
+        "staticPageGenerationTimeout": config.static_page_generation_timeout,
     }
     if transpile_packages:
         next_config["transpilePackages"] = list(

+ 13 - 5
tests/units/test_prerequisites.py

@@ -24,7 +24,15 @@ from reflex.utils.prerequisites import (
                 app_name="test",
             ),
             False,
-            'module.exports = {basePath: "", compress: true, reactStrictMode: true, trailingSlash: true};',
+            'module.exports = {basePath: "", compress: true, reactStrictMode: true, trailingSlash: true, staticPageGenerationTimeout: 60};',
+        ),
+        (
+            Config(
+                app_name="test",
+                static_page_generation_timeout=30,
+            ),
+            False,
+            'module.exports = {basePath: "", compress: true, reactStrictMode: true, trailingSlash: true, staticPageGenerationTimeout: 30};',
         ),
         (
             Config(
@@ -32,7 +40,7 @@ from reflex.utils.prerequisites import (
                 next_compression=False,
             ),
             False,
-            'module.exports = {basePath: "", compress: false, reactStrictMode: true, trailingSlash: true};',
+            'module.exports = {basePath: "", compress: false, reactStrictMode: true, trailingSlash: true, staticPageGenerationTimeout: 60};',
         ),
         (
             Config(
@@ -40,7 +48,7 @@ from reflex.utils.prerequisites import (
                 frontend_path="/test",
             ),
             False,
-            'module.exports = {basePath: "/test", compress: true, reactStrictMode: true, trailingSlash: true};',
+            'module.exports = {basePath: "/test", compress: true, reactStrictMode: true, trailingSlash: true, staticPageGenerationTimeout: 60};',
         ),
         (
             Config(
@@ -49,14 +57,14 @@ from reflex.utils.prerequisites import (
                 next_compression=False,
             ),
             False,
-            'module.exports = {basePath: "/test", compress: false, reactStrictMode: true, trailingSlash: true};',
+            'module.exports = {basePath: "/test", compress: false, reactStrictMode: true, trailingSlash: true, staticPageGenerationTimeout: 60};',
         ),
         (
             Config(
                 app_name="test",
             ),
             True,
-            'module.exports = {basePath: "", compress: true, reactStrictMode: true, trailingSlash: true, output: "export", distDir: "_static"};',
+            'module.exports = {basePath: "", compress: true, reactStrictMode: true, trailingSlash: true, staticPageGenerationTimeout: 60, output: "export", distDir: "_static"};',
         ),
     ],
 )