kemalcr / kemal

Fast, Effective, Simple Web Framework
https://kemalcr.com
MIT License
3.65k stars 189 forks source link

bug:Unhandled exception: Not Implemented: Crystal::System::Signal.trap (NotImplementedError) from D:\Dev\Crystal\src\crystal\system\win32\signal.cr:5 in 'trap' #665

Closed lansn closed 7 months ago

lansn commented 1 year ago

Description

[Unhandled exception: Not Implemented: Crystal::System::Signal.trap (NotImplementedError) from D:\Dev\Crystal\src\crystal\system\win32\signal.cr:5 in 'trap']

Steps to Reproduce

step 1: create file: src/web.cr require "kemal"

get "/" do "Hello World!" end

Kemal.run

step 2: crystal run src/web.cr

crystal run src\web.cr Unhandled exception: Not Implemented: Crystal::System::Signal.trap (NotImplementedError) from D:\Dev\Crystal\src\crystal\system\win32\signal.cr:5 in 'trap' from D:\Dev\Crystal\src\signal.cr:117 in 'trap' from lib\kemal\src\kemal.cr:92 in 'setup_trap_signal' from lib\kemal\src\kemal.cr:39 in 'run' from lib\kemal\src\kemal.cr:16 in 'run' from src\web.cr:11 in 'crystal_main' from D:\Dev\Crystal\src\crystal\main.cr:129 in 'main_user_code' from D:\Dev\Crystal\src\crystal\main.cr:115 in 'main' from D:\Dev\Crystal\src\crystal\main.cr:141 in 'main' from D:\Dev\Crystal\src\crystal\system\win32\wmain.cr:37 in 'wmain' from D:\a_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288 in 'scrt_common_main_seh' from C:\Windows\System32\KERNEL32.DLL +95044 in 'BaseThreadInitThunk' from C:\Windows\SYSTEM32\ntdll.dll +337585 in 'RtlUserThreadStart' Error deleting file: 'C:\Users\bl\AppData\Local\crystal\cache\crystal-run-web.exe.tmp.exe': Permission denied (File::AccessDeniedError) from D:\a\crystal\crystal\src\crystal\system\win32\file.cr:283 in 'delete:raise_on_missing' from D:\a\crystal\crystal\src\compiler\crystal\command.cr:266 in 'execute' from D:\a\crystal\crystal\src\compiler\crystal\command.cr:231 in 'run_command' from D:\a\crystal\crystal\src\compiler\crystal.cr:11 in 'crystal_main' from D:\a\crystal\crystal\src\crystal\main.cr:141 in 'main' from D:\a\crystal\crystal\src\crystal\system\win32\wmain.cr:37 in 'wmain' from D:\a_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288 in 'scrt_common_main_seh' from C:\Windows\System32\KERNEL32.DLL +95044 in 'BaseThreadInitThunk' from C:\Windows\SYSTEM32\ntdll.dll +337585 in 'RtlUserThreadStart' Error: you've found a bug in the Crystal compiler. Please open an issue, including source code that will allow us to reproduce the bug: https://github.com/crystal-lang/crystal/issues

Versions

win10 x64 22H2 19045.3448, crystal 1.9.2, kemal 1.4.0

grkek commented 1 year ago

I remember Kemal implementing the platform agnostic trapping, but now when I view the source code it seems like it might have been lost in commits.

Anyway you can extend the Kemal module for now for a temporary fix

module Kemal
  private def self.setup_trap_signal
    Process.on_interrupt {
      Kemal.stop
      exit
    }
  end
end

Save this into a file named extension.cr and require it right after you require the Kemal lib, for example:

require "kemal"
require "./extension.cr"

I will make a PR to fix this issue.

Sija commented 7 months ago

Should be fixed by #666