|
1 | 1 | // Test tools |
2 | 2 | import zlib from 'zlib'; |
3 | 3 | import crypto from 'crypto'; |
4 | | -import {spawn} from 'child_process'; |
5 | 4 | import http from 'http'; |
6 | 5 | import fs from 'fs'; |
7 | 6 | import stream from 'stream'; |
@@ -844,78 +843,6 @@ describe('node-fetch', () => { |
844 | 843 | }); |
845 | 844 | }); |
846 | 845 |
|
847 | | - it('should allow custom timeout', () => { |
848 | | - const url = `${base}timeout`; |
849 | | - const options = { |
850 | | - timeout: 20 |
851 | | - }; |
852 | | - return expect(fetch(url, options)).to.eventually.be.rejected |
853 | | - .and.be.an.instanceOf(FetchError) |
854 | | - .and.have.property('type', 'request-timeout'); |
855 | | - }); |
856 | | - |
857 | | - it('should allow custom timeout on response body', () => { |
858 | | - const url = `${base}slow`; |
859 | | - const options = { |
860 | | - timeout: 20 |
861 | | - }; |
862 | | - return fetch(url, options).then(res => { |
863 | | - expect(res.ok).to.be.true; |
864 | | - return expect(res.text()).to.eventually.be.rejected |
865 | | - .and.be.an.instanceOf(FetchError) |
866 | | - .and.have.property('type', 'body-timeout'); |
867 | | - }); |
868 | | - }); |
869 | | - |
870 | | - it('should not allow socket timeout before body is read', () => { |
871 | | - const url = `${base}slow`; |
872 | | - const options = { |
873 | | - timeout: 100 |
874 | | - }; |
875 | | - // Await the response, then delay, allowing enough time for the timeout |
876 | | - // to be created just before the socket timeout |
877 | | - return fetch(url, options).then(delay(75)).then(res => { |
878 | | - expect(res.ok).to.be.true; |
879 | | - return expect(res.text()).to.eventually.be.rejected |
880 | | - .and.be.an.instanceOf(FetchError) |
881 | | - .and.have.property('type', 'body-timeout'); |
882 | | - }); |
883 | | - }); |
884 | | - |
885 | | - it('should allow custom timeout on redirected requests', () => { |
886 | | - const url = `${base}redirect/slow-chain`; |
887 | | - const options = { |
888 | | - timeout: 20 |
889 | | - }; |
890 | | - return expect(fetch(url, options)).to.eventually.be.rejected |
891 | | - .and.be.an.instanceOf(FetchError) |
892 | | - .and.have.property('type', 'request-timeout'); |
893 | | - }); |
894 | | - |
895 | | - it('should clear internal timeout on fetch response', function (done) { |
896 | | - this.timeout(2000); |
897 | | - spawn('node', ['-e', `require(’./’)(’${base}hello’, { timeout: 10000 })`]) |
898 | | - .on('exit', () => { |
899 | | - done(); |
900 | | - }); |
901 | | - }); |
902 | | - |
903 | | - it('should clear internal timeout on fetch redirect', function (done) { |
904 | | - this.timeout(2000); |
905 | | - spawn('node', ['-e', `require(’./’)(’${base}redirect/301’, { timeout: 10000 })`]) |
906 | | - .on('exit', () => { |
907 | | - done(); |
908 | | - }); |
909 | | - }); |
910 | | - |
911 | | - it('should clear internal timeout on fetch error', function (done) { |
912 | | - this.timeout(2000); |
913 | | - spawn('node', ['-e', `require(’./’)(’${base}error/reset’, { timeout: 10000 })`]) |
914 | | - .on('exit', () => { |
915 | | - done(); |
916 | | - }); |
917 | | - }); |
918 | | - |
919 | 846 | it('should support request cancellation with signal', function () { |
920 | 847 | this.timeout(500); |
921 | 848 | const controller = new AbortController(); |
@@ -967,23 +894,6 @@ describe('node-fetch', () => { |
967 | 894 | }); |
968 | 895 | }); |
969 | 896 |
|
970 | | - it('should clear internal timeout when request is cancelled with an AbortSignal', function (done) { |
971 | | - this.timeout(2000); |
972 | | - const script = ` |
973 | | - var AbortController = require(’abortcontroller-polyfill/dist/cjs-ponyfill’).AbortController; |
974 | | - var controller = new AbortController(); |
975 | | - require(’./’)( |
976 | | - ’${base}timeout’, |
977 | | - { signal: controller.signal, timeout: 10000 } |
978 | | - ); |
979 | | - setTimeout(function () { controller.abort(); }, 20); |
980 | | - `; |
981 | | - spawn('node', ['-e', script]) |
982 | | - .on('exit', () => { |
983 | | - done(); |
984 | | - }); |
985 | | - }); |
986 | | - |
987 | 897 | it('should remove internal AbortSignal event listener after request is aborted', () => { |
988 | 898 | const controller = new AbortController(); |
989 | 899 | const {signal} = controller; |
|
0 commit comments