When using ValidatedMethod error with fibers node module

## There is an issue with `node-fibers` ## `/node_modules/fibers/bin/browser-undefined-undefined/fibers.node` is missing.  Try running this to fix the issue: undefined /node_modules/fibers/build

Uncaught Error: Missing binary. See message above.
    at fibers.js (modules.js?hash=1058de750d1ae6c548188f519f27a5e8e38db9c4:25124)
    at fileEvaluate (modules-runtime.js?hash=5e485d3e2a49d2506f7ca0df72fcd6a3216a83a5:353)
    at require (modules-runtime.js?hash=5e485d3e2a49d2506f7ca0df72fcd6a3216a83a5:248)
    at future.js (modules.js?hash=1058de750d1ae6c548188f519f27a5e8e38db9c4:24620)
    at fileEvaluate (modules-runtime.js?hash=5e485d3e2a49d2506f7ca0df72fcd6a3216a83a5:353)
    at require (modules-runtime.js?hash=5e485d3e2a49d2506f7ca0df72fcd6a3216a83a5:248)
    at methods.js (methods.js:1)
    at fileEvaluate (modules-runtime.js?hash=5e485d3e2a49d2506f7ca0df72fcd6a3216a83a5:353)
    at require (modules-runtime.js?hash=5e485d3e2a49d2506f7ca0df72fcd6a3216a83a5:248)
    at company.js (company.js:1)

import Future from ‘fibers/future’;
import { ValidatedMethod } from ‘meteor/mdg:validated-method’;

causes the above errors. Anyone got an idea why?

I’m not sure why you’re doing this. Fibers are automatically included in server builds.

Fibers cannot be used on the client - which I’m guessing is what you’re seeing here.

What are you trying to do?

No I am using them on server within a method. I am using validat vat node module and I need to return messages back to the client.

import Future from 'fibers/future'
import { check } from 'meteor/check'
import validate from 'validate-vat';


Meteor.methods({
  'checkVat'(vat_number, country_code) {

    const validate_vat = new Future();

    check(country_code, String);
    check(vat_number, String);

    console.log('country_code' + country_code);
    console.log('vat_number' + vat_number);


    validate( country_code,  vat_number,  function(err, validationInfo) {
        if (err) {
          console.log(err);
          validate_vat.throw(err);
        } else {
          console.log(validationInfo);
          validate_vat.return(validationInfo);
        }
    });

    return validate_vat.wait();

  },

Well, your original code uses ValidatedMethod, which has client and server components. The error reported:

## There is an issue with `node-fibers` ## `/node_modules/fibers/bin/browser-undefined-undefined/fibers.node` is missing.  Try running this to fix the issue: undefined /node_modules/fibers/build

specifically references the browser: “/node_modules/fibers/bin/browser-undefined-undefined/fibers.node is missing”.

I think you’re importing, or otherwise making available, server-side-specific code (Fibers) into the client. You could consider wrapping the ValidatedMethod#run method with a Meteor.isServer block.

1 Like

I tried your suggestion using Meteor.wrapAsync
But It’s always returning ‘oops’, ‘something broke’

100 % I did a mistake in my code, but I cannot figure it out.

const myFunc = validate( country_code,  vat_number,  function(err, validationInfo) {
        if (err) {
          console.log(err);
          return err;
        } else {
          console.log(validationInfo);
          return validationInfo;
        }
    });

    const test = Meteor.wrapAsync(myFunc);

    try {
      return test(country_code, vat_nunmber);
    } catch (err) {
      throw new Meteor.Error('oops', 'something broke');
    }
const myFunc = Meteor.wrapAsync(validate);
try {
  return myFunc(country_code, vat_number);
} catch (err) {
  throw new Meteor.Error('oops', 'something broke');
}

Yeah I’ve got It. Thank you so much Rob. It’s simple. So no need for the npm package fibers, that I have installed.

1 Like