Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use hash trie data file on Node.js 8.9.3 using module version 3.2.18-dev #22

Closed
prachaquanttech opened this issue Dec 9, 2017 · 7 comments

Comments

@prachaquanttech
Copy link

prachaquanttech commented Dec 9, 2017

using this config

const fiftyonedegreescoreConfig = {

 dataFile: 'static/51degrees/51Degrees-EnterpriseV3.4.trie',
 properties: [
   'HardwareVendor', 
   'HardwareModel', 
   'HardwareFamily', 
   'PriceBand', 
   'PlatformName', 
   'PlatformVersion', 
   'ScreenPixelsHeight', 
   'ScreenPixelsWidth',
   'ReleaseMonth',
   'ReleaseYear',
   'DeviceType',
   'HardwareModelVariants',
 ],
 cacheSize: 10000,
 poolSize: 20,
}
const provider = DeviceDetection.provider(fiftyonedegreescoreConfig) //Error was throw here
const match =  provider.getMatch(ctx.header['user-agent'])
match.close()

Error: Illegal arguments for construction of _exports_Provider
Please help

@prachaquanttech
Copy link
Author

Update
if I remove properties, cacheSize and poolSize from the config, Code will run fine.

@JoshGrew51D
Copy link
Contributor

Hi There

You should only need to remove poolSize as this is a Pattern only option. Hash Trie does not have a workset pool like Pattern. It's matches consist of Device offsets which are smaller than Pattern worksets. As a result they are calculated on the fly.

Let me know how you get on.

@prachaquanttech
Copy link
Author

Thanks for the answer
if add "properties" option back, It will throw "segmentation fault".

@JoshGrew51D
Copy link
Contributor

Which version of the data file are you using currently?

@prachaquanttech
Copy link
Author

51Degrees-EnterpriseV3.4.trie

@JoshGrew51D
Copy link
Contributor

Of course, sorry ignore me.

I have modified the example above with some changes to the configuration. Properties are not stored as an array but as a comma separated string. The keys in the config are also surrounded by quotes.

Try this and let me know what you get back.

Would you also be able to send over the code where you reference the Device Detection module in: DeviceDetection.provider

const fiftyonedegreescoreConfig = {'dataFile' : 'static/51degrees/51Degrees-EnterpriseV3.4.trie',
    'properties' : 'HardwareVendor,HardwareModel,HardwareFamily,PriceBand,PlatformName,PlatformVersion,ScreenPixelsHeight,ScreenPixelsWidth,ReleaseMonth,ReleaseYear,DeviceType,HardwareModelVariants'}

const provider = DeviceDetection.provider(fiftyonedegreescoreConfig)
const match =  provider.getMatch(ctx.header['user-agent'])
match.close()

@prachaquanttech
Copy link
Author

prachaquanttech commented Dec 12, 2017

This code work

const fiftyonedegreescoreConfig = {'dataFile' : 'static/51degrees/51Degrees-EnterpriseV3.4.trie',
    'properties' : 'HardwareVendor,HardwareModel,HardwareFamily,PriceBand,PlatformName,PlatformVersion,ScreenPixelsHeight,ScreenPixelsWidth,ReleaseMonth,ReleaseYear,DeviceType,HardwareModelVariants'}

const provider = DeviceDetection.provider(fiftyonedegreescoreConfig)
const match =  provider.getMatch(ctx.header['user-agent'])
match.close()

BTW we use module this in Koa.js. Can I write provider.getMatch(ctx.request) like in Express.js?

Thanks a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants