select2 / select2/select2

"the results could not be loaded" error condition doesn't work with timeout

Open
#6,372 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
25.9k
Forks
6.1k
Avg merge
8d 53m
Merged PRs (30d)
4

Description

"the results could not be loaded" error condition is correctly generated for errors like 404, 500, but not for timeout condition

Minimal case:

Browse to http://localhost/select.html

Expected: After 1000 ms, "the results could not be loaded" is displayed right below dropdown

Actual: No error is displayed

sleep.php:

<?php
sleep (20);

select.html

<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<link href="select2.css" rel="stylesheet">
</head>
<body>
<select id="dropdown"></select>
<script src="jquery-3.7.1.js"></script>
<script src="select2.full.js"></script>
<script>
$(function(){
	$('#dropdown').select2({
		debug:true,
		ajax: {
			url: '/sleep.php',
			timeout: 1000,
			error: function(a,b,c) {
				console.log("oops");
			},
			data: function (params) {
				return {
					query: params.term
				}
			},
			
		},
		width: "50%"
	})
});
</script>
</body>
</html>

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the timeout with the provided select.html and sleep.php case, then inspect the AJAX timeout and error-handling path in select2.full.js. Confirm that a 1000 ms timeout displays "the results could not be loaded" below the dropdown, while the existing 404 and 500 behavior remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, jquery
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.