Using yoman generator - Run Time Error: Prerendering failed because of error: ReferenceError: EventSource is not defined #627

Closed
opened 2025-08-09 17:17:01 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @colm-quinn on 6/27/2017

Hi,
I'm using the generator to create an aspnetcore app, with a servicestack rest server as a backend for my data handling. On the ServiceStack Service, there will be an SSE connection for communication of server update messages.

When trying to add the SSE Client, which uses EventSource objects, I can no longer run the AspNetCore service. Instead I get the following error when making a connection via the web browser:

Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 GET http://localhost:5000/
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1]
      Executing action method WebappTestserver.Controllers.HomeController.Index (WebApp.AspNetCore) with arguments ((null)) - ModelState is Valid
info: Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ViewResultExecutor[1]
      Executing ViewResult, running view at path /Views/Home/Index.cshtml.
info: Microsoft.Extensions.DependencyInjection.DataProtectionServices[0]
      User profile is available. Using 'C:\Users\molc\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
      Executed action WebappTestserver.Controllers.HomeController.Index (WebApp.AspNetCore) in 3136.4834ms
fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[0]
      An unhandled exception has occurred: Call to Node module failed with error: Prerendering failed because of error: ReferenceError: EventSource is not defined
    at ServerEventsClient.start (F:\src\docHQ\WebApp\WebApp.AspNetCore\ClientApp\dist\main-server.js:9237:23)
    at Object.exports.__esModule (F:\src\docHQ\WebApp\WebApp.AspNetCore\ClientApp\dist\main-server.js:2863:6)
    at __webpack_require__ (F:\src\docHQ\WebApp\WebApp.AspNetCore\ClientApp\dist\main-server.js:20:30)
    at Object.defineProperty.value (F:\src\docHQ\WebApp\WebApp.AspNetCore\ClientApp\dist\main-server.js:11171:14)
    at __webpack_require__ (F:\src\docHQ\WebApp\WebApp.AspNetCore\ClientApp\dist\main-server.js:20:30)
    at Object.<anonymous> (F:\src\docHQ\WebApp\WebApp.AspNetCore\ClientApp\dist\main-server.js:10067:22)
    at __webpack_require__ (F:\src\docHQ\WebApp\WebApp.AspNetCore\ClientApp\dist\main-server.js:20:30)
    at Object.defineProperty.value (F:\src\docHQ\WebApp\WebApp.AspNetCore\ClientApp\dist\main-server.js:10914:15)
    at __webpack_require__ (F:\src\docHQ\WebApp\WebApp.AspNetCore\ClientApp\dist\main-server.js:20:30)
    at F:\src\docHQ\WebApp\WebApp.AspNetCore\ClientApp\dist\main-server.js:66:18

It looks like EventSource Polyfill doesn't work with the aspnet prerendering, but I can't figure out how to enable it. Any ideas?

*Originally created by @colm-quinn on 6/27/2017* Hi, I'm using the generator to create an aspnetcore app, with a servicestack rest server as a backend for my data handling. On the ServiceStack Service, there will be an SSE connection for communication of server update messages. When trying to add the SSE Client, which uses EventSource objects, I can no longer run the AspNetCore service. Instead I get the following error when making a connection via the web browser: ``` Now listening on: http://localhost:5000 Application started. Press Ctrl+C to shut down. info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1] Request starting HTTP/1.1 GET http://localhost:5000/ info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1] Executing action method WebappTestserver.Controllers.HomeController.Index (WebApp.AspNetCore) with arguments ((null)) - ModelState is Valid info: Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ViewResultExecutor[1] Executing ViewResult, running view at path /Views/Home/Index.cshtml. info: Microsoft.Extensions.DependencyInjection.DataProtectionServices[0] User profile is available. Using 'C:\Users\molc\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest. info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2] Executed action WebappTestserver.Controllers.HomeController.Index (WebApp.AspNetCore) in 3136.4834ms fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[0] An unhandled exception has occurred: Call to Node module failed with error: Prerendering failed because of error: ReferenceError: EventSource is not defined at ServerEventsClient.start (F:\src\docHQ\WebApp\WebApp.AspNetCore\ClientApp\dist\main-server.js:9237:23) at Object.exports.__esModule (F:\src\docHQ\WebApp\WebApp.AspNetCore\ClientApp\dist\main-server.js:2863:6) at __webpack_require__ (F:\src\docHQ\WebApp\WebApp.AspNetCore\ClientApp\dist\main-server.js:20:30) at Object.defineProperty.value (F:\src\docHQ\WebApp\WebApp.AspNetCore\ClientApp\dist\main-server.js:11171:14) at __webpack_require__ (F:\src\docHQ\WebApp\WebApp.AspNetCore\ClientApp\dist\main-server.js:20:30) at Object.<anonymous> (F:\src\docHQ\WebApp\WebApp.AspNetCore\ClientApp\dist\main-server.js:10067:22) at __webpack_require__ (F:\src\docHQ\WebApp\WebApp.AspNetCore\ClientApp\dist\main-server.js:20:30) at Object.defineProperty.value (F:\src\docHQ\WebApp\WebApp.AspNetCore\ClientApp\dist\main-server.js:10914:15) at __webpack_require__ (F:\src\docHQ\WebApp\WebApp.AspNetCore\ClientApp\dist\main-server.js:20:30) at F:\src\docHQ\WebApp\WebApp.AspNetCore\ClientApp\dist\main-server.js:66:18 ``` It looks like EventSource Polyfill doesn't work with the aspnet prerendering, but I can't figure out how to enable it. Any ideas?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#627
No description provided.