transient-error-lookup.js 776 B

123456789101112131415161718192021
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.TransientErrorLookup = void 0;
  6. // This simple piece of code is factored out into a separate class to make it
  7. // easy to stub it out in tests. It's hard, if not impossible, to cause a
  8. // transient error on demand in tests.
  9. class TransientErrorLookup {
  10. isTransientError(error) {
  11. // This list of transient errors comes from Microsoft implementation of SqlClient:
  12. // - https://github.com/dotnet/corefx/blob/master/src/System.Data.SqlClient/src/System/Data/SqlClient/SqlInternalConnectionTds.cs#L115
  13. const transientErrors = [4060, 10928, 10929, 40197, 40501, 40613];
  14. return transientErrors.indexOf(error) !== -1;
  15. }
  16. }
  17. exports.TransientErrorLookup = TransientErrorLookup;