NancyFx / Nancy

Lightweight, low-ceremony, framework for building HTTP based services on .Net and Mono
http://nancyfx.org
MIT License
7.15k stars 1.47k forks source link

CancellationToken never changes in Nancy.Hosting.Self on Canceled Browser Request #2934

Open gerardcarbo opened 5 years ago

gerardcarbo commented 5 years ago

Prerequisites

Description

After a request is canceled in the browser, using Asynch Route Handling and Nancy.Hosting.Self, the provided CancellationToken never changes, and CancellationToken.IsCancellationRequested is always false.

Steps to Reproduce

This code never breaks when 'someRequest' is canceled in the browser:

Get["/someRequest/", true] = async (p, ct) => {
    await Task.Run(() =>
    {
        while(true){
            Thread.Sleep(100); //do work
            if(ct.IsCancellationRequested){
                break;
            }
        }
    }
};

System Configuration

Windows 10 x64, Visual Studio Comunity 2017, .Net Framework 4.6.1

yar1k0v commented 5 years ago

BTW, what's new in the version 1.4.5 ? I cant find any release notes on it.