meteor/meteor · error · Error

History.go: History.go requires a positive or negative integ

Error message

History.go: History.go requires a positive or negative integer passed.

What it means

History.go(index) only accepts a non-zero integer: positive moves forward, negative moves backward. Passing 0 (or a value that is neither >0 nor <0) falls through both branches and throws, because moving by zero states is meaningless.

Source

Thrown at packages/deprecated/jquery-history/history.js:1576

			// Prepare
			var i;

			// Handle
			if ( index > 0 ) {
				// Forward
				for ( i=1; i<=index; ++i ) {
					History.forward(queue);
				}
			}
			else if ( index < 0 ) {
				// Backward
				for ( i=-1; i>=index; --i ) {
					History.back(queue);
				}
			}
			else {
				throw new Error('History.go: History.go requires a positive or negative integer passed.');
			}

			// Chain
			return History;
		};


		// ====================================================================
		// HTML5 State Support

		// Non-Native pushState Implementation
		if ( History.emulated.pushState ) {
			/*
			 * Provide Skeleton for HTML4 Browsers
			 */

			// Prepare
			var emptyFunction = function(){};

View on GitHub (pinned to 5076d2f818)

Solutions

  1. Guard: only call History.go when index is a non-zero integer.
  2. No-op explicitly when index === 0 rather than calling History.go.
  3. Coerce and validate: if (!index || !Number.isInteger(index)) return;

Example fix

// before
History.go(delta); // delta may be 0

// after
if (Number.isInteger(delta) && delta !== 0) History.go(delta);
Defensive patterns

Strategy: validation

Validate before calling

function historyGo(index) {
  if (!Number.isInteger(index) || index === 0) return;
  History.go(index);
}

Type guard

function isNonZeroInteger(v) {
  return Number.isInteger(v) && v !== 0;
}

Prevention

When it happens

Trigger: Calling History.go(0); calling History.go(someVar) where someVar is 0, undefined coerced to 0, or NaN.

Common situations: Passing a computed delta that can be zero; user input (e.g. 'go N steps') with N=0; off-by-one in pagination logic.

Related errors


AI-assisted analysis of meteor/meteor@5076d2f818 (2026-08-13). Data as JSON: /api/errors/a92f4bb5a27f5d7d. Report an issue: GitHub.