web-dev-qa-db-fra.com

Échec de la demande de récupération dans Node.js (socket réseau client déconnecté avant l'établissement de la connexion TLS sécurisée)

Je viens de charger le code standard du Tensorflow Toxicity classifier exemple de ceci page Github .

Voici le code en index.js -

const toxicity = require('@tensorflow-models/toxicity');

const threshold = 0.9;

toxicity.load(threshold).then((model) => {
  const sentences = ['you suck'];

  model.classify(sentences).then((predictions) => {
    console.log(predictions);
  });
});

Si vous avez besoin du projet complet, voici le GitHub repo .

Mais lorsque j'exécute le code, cela me donne l'erreur suivante -

(node:2180) UnhandledPromiseRejectionWarning: FetchError: request to https://storage.googleapis.com/tfjs-models/savedmodel/universal_sentence_encoder/vocab.json failed, reason: Client network socket disconnected before secure TLS connection was established
    at ClientRequest.<anonymous> (D:\xampp\htdocs\nodejs-projects\simple-node\node_modules\node-fetch\lib\index.js:1393:11)
    at ClientRequest.emit (events.js:310:20)
    at TLSSocket.socketErrorListener (_http_client.js:426:9)
    at TLSSocket.emit (events.js:310:20)
    at emitErrorNT (internal/streams/destroy.js:92:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
(node:2180) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:2180) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:2180) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

J'ai recherché l'erreur dans Google, il y a beaucoup de questions comme celles-ci mais aucune réponse valide.

Voici quelques choses que j'ai déjà faites pour éliminer un problème possible -

  1. Clean a installé la dernière version de Node.js
  2. Vérifié si j'ai un proxy configuré (je ne l'ai jamais fait ...)

Information additionnelle -

Système d'exploitation: Windows 10 (64 bits) (Version 1909) Node Version: v12.16.3

Toute aide serait très appréciée.

9
Evading Shadows

S'il ne s'agit que d'un avertissement, vous pouvez utiliser l'argument;

--unhandled-rejections=none

Ci-dessous est copié de la documentation node.js;

Ajouté dans: v12.0.0, v10.17.0

Par défaut, tous les rejets non gérés déclenchent un avertissement plus un avertissement d'obsolescence pour le tout premier rejet non géré au cas où aucun hook unhandledRejection n'est utilisé.

L'utilisation de cet indicateur permet de changer ce qui doit se passer lorsqu'un rejet non géré se produit. Un des trois modes peut être choisi:

strict: Raise the unhandled rejection as an uncaught exception.
warn: Always trigger a warning, no matter if the unhandledRejection hook is set or not but do not print the deprecation warning.
none: Silence all warnings.

Vous pouvez en savoir plus ici https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode

0
alfred