PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: sindresorhus/got (ts)

Issue:
Cannot cancel when timeout option is set
When the options.timeout, or options.timeout.request, is set, the `pCancelable` promise is wrapped in a `pTimeout` promise. This prevents the possibility of calling cancel.

See [index.js#L130-L132](https://github.com/sindresorhus/got/blob/master/index.js#L130-L132).

Is this intentional?

Pull request:
Fix cancel when timeout exists - fixes #344
Fixes https://github.com/sindresorhus/got/issues/344

Patch:
diff --git a/index.js b/index.js
index 0631aa2..e11bfd2 100644
--- a/index.js
+++ b/index.js
@@ -270,7 +270,7 @@ function asPromise(opts) {
 
 	const proxy = new EventEmitter();
 
-	const promise = timeoutFn(new PCancelable((onCancel, resolve, reject) => {
+	const cancelable = new PCancelable((onCancel, resolve, reject) => {
 		const ee = requestAsEventEmitter(opts);
 		let cancelOnRequest = false;
 
@@ -332,7 +332,11 @@ function asPromise(opts) {
 		ee.on('error', reject);
 		ee.on('uploadProgress', proxy.emit.bind(proxy, 'uploadProgress'));
 		ee.on('downloadProgress', proxy.emit.bind(proxy, 'downloadProgress'));
-	}));
+	});
+
+	const promise = timeoutFn(cancelable);
+
+	promise.cancel = cancelable.cancel.bind(cancelable);
 
 	promise.on = (name, fn) => {
 		proxy.on(name, fn);
@@ -567,6 +571,7 @@ for (const method of methods) {
 class StdError extends Error {
 	constructor(message, error, opts) {
 		super(message);
+		Error.captureStackTrace(this, this.constructor);
 		this.name = 'StdError';
 
 		if (error.code !== undefined) {


Test patch:
diff --git a/test/cancel.js b/test/cancel.js
index eada726..3ed0fdf 100644
--- a/test/cancel.js
+++ b/test/cancel.js
@@ -47,6 +47,25 @@ test('cancel in-progress request', async t => {
 	await t.notThrows(helper.aborted, 'Request finished instead of aborting.');
 });
 
+test('cancel in-progress request with timeout', async t => {
+	const helper = await createAbortServer();
+	const body = new Readable({
+		read() {}
+	});
+	body.push('1');
+
+	const p = got(helper.url, {body, timeout: 10000});
+
+	// Wait for the stream to be established before canceling
+	setTimeout(() => {
+		p.cancel();
+		body.push(null);
+	}, 100);
+
+	await t.throws(p, PCancelable.CancelError);
+	await t.notThrows(helper.aborted, 'Request finished instead of aborting.');
+});
+
 test('cancel immediately', async t => {
 	const s = await createServer();
 	const aborted = new Promise((resolve, reject) => {
Repository: mirage/decompress (ocaml)

Issue:

Pull request:
Fix our last test about LZO from MirageVPN

Patch:
diff --git a/lib/lzo.ml b/lib/lzo.ml
index 97144ff..42cc409 100644
--- a/lib/lzo.ml
+++ b/lib/lzo.ml
@@ -334,7 +334,7 @@ let fiber : (unit, [> error ]) t =
     read byte >>= fun h ->
     let state = State.of_int (Char.code chr land 0b11) in
     let off = (Char.code h lsl 2) + (Char.code chr lsr 2) + 2049 in
-    copy ~off ~len:1 state
+    copy ~off ~len:1 state >>= fun () -> m
   | '\016' .. '\031', _ ->
     let length = Char.code chr land 0b111 in
     let with_length len =
@@ -390,7 +390,7 @@ let fiber : (unit, [> error ]) t =
     transmit ~len:4 State._0 >>= fun () -> fiber
   | '\022' .. '\255' as chr ->
     let len = Char.code chr - 17 in
-    junk byte >>= fun () -> transmit ~len State._0
+    junk byte >>= fun () -> transmit ~len State._0 >>= fun () -> fiber
 
 let uncompress input output : (bigstring, [> error ]) result =
   let v = {i= input; i_pos= 0; o= output; o_pos= 0; state= State._0} in


Test patch:
diff --git a/test/test_lzo.ml b/test/test_lzo.ml
index b459fa8..801e8f5 100644
--- a/test/test_lzo.ml
+++ b/test/test_lzo.ml
@@ -604,7 +604,7 @@ let () =
       ( "lzo"
       , [
           test_lzo_0 (); test_lzo_1 (); test_lzo_2 (); test_lzo_3 ()
-        ; test_lzo_4 (); test_lzo_5 (); test_lzo_6 () (* ; test_lzo_7 () *)
+        ; test_lzo_4 (); test_lzo_5 (); test_lzo_6 () ; test_lzo_7 ()
         ; test_lzo_8 (); test_lzo_9 (); test_lzo_10 (); test_lzo_11 ()
         ; test_lzo_12 (); test_lzo_13 (); test_lzo_14 (); test_lzo_15 ()
         ] )
Repository: vaskoz/dailycodingproblem-go (go)

Issue:
Day 374
Good morning! Here's your coding interview problem for today.

This problem was asked by Amazon.

Given a sorted array `arr` of distinct integers, return the lowest index `i` for which `arr[i] == i`. Return `null` if there is no such index.

For example, given the array `[-5, -3, 2, 3]`, return `2` since `arr[2] == 2`. Even though `arr[3] == 3`, we return `2` since it's the lowest index.

Pull request:
Day374
Resolves #754.

Patch:
diff --git a/README.md b/README.md
index 1f0990d..c615aea 100644
--- a/README.md
+++ b/README.md
@@ -369,4 +369,5 @@ problems from
 * [Day 371](https://github.com/vaskoz/dailycodingproblem-go/issues/750)
 * [Day 372](https://github.com/vaskoz/dailycodingproblem-go/issues/748)
 * [Day 373](https://github.com/vaskoz/dailycodingproblem-go/issues/752)
+* [Day 374](https://github.com/vaskoz/dailycodingproblem-go/issues/754)
 
diff --git a/day374/problem.go b/day374/problem.go
new file mode 100644
index 0000000..b97c1b1
--- /dev/null
+++ b/day374/problem.go
@@ -0,0 +1,38 @@
+package day374
+
+import (
+	"errors"
+	"sort"
+)
+
+var (
+	errNoSuchIndex    = errors.New("no index is a fixed point")
+	errInputNotSorted = errors.New("input is not sorted and must be")
+)
+
+// LowestFixedPoint returns the lowest fixed point index.
+// If no such index exists, it returns an error.
+// Also returns an error if input is not sorted.
+// Runs in O(log N) worst case time thanks to binary search.
+func LowestFixedPoint(sorted []int) (int, error) {
+	if !sort.IntsAreSorted(sorted) {
+		return 0, errInputNotSorted
+	}
+
+	for lo, hi := 0, len(sorted); lo <= hi; {
+		switch mid := (lo + hi) / 2; {
+		case sorted[mid] == mid:
+			if hi-lo == 0 {
+				return mid, nil
+			}
+
+			hi = mid
+		case sorted[mid] < mid:
+			lo = mid + 1
+		default:
+			hi = mid - 1
+		}
+	}
+
+	return 0, errNoSuchIndex
+}


Test patch:
diff --git a/day374/problem_test.go b/day374/problem_test.go
new file mode 100644
index 0000000..b8462cb
--- /dev/null
+++ b/day374/problem_test.go
@@ -0,0 +1,34 @@
+package day374
+
+import "testing"
+
+// nolint
+var testcases = []struct {
+	input       []int
+	expected    int
+	expectedErr error
+}{
+	{[]int{-5, -3, 2, 3}, 2, nil},
+	{[]int{2, 3, -3}, 0, errInputNotSorted},
+	{[]int{-5, -3, 5, 13}, 0, errNoSuchIndex},
+	{[]int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, 0, nil},
+	{[]int{-15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, 1, 15}, 15, nil},
+}
+
+func TestLowestFixedPoint(t *testing.T) {
+	t.Parallel()
+
+	for _, tc := range testcases {
+		if res, err := LowestFixedPoint(tc.input); res != tc.expected || err != tc.expectedErr {
+			t.Errorf("Expected (%v,%v), got (%v,%v)", tc.expected, tc.expectedErr, res, err)
+		}
+	}
+}
+
+func BenchmarkLowestFixedPoint(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		for _, tc := range testcases {
+			LowestFixedPoint(tc.input) // nolint
+		}
+	}
+}