worker-planet icon indicating copy to clipboard operation
worker-planet copied to clipboard

cant get it to run

Open the-hidden-eye opened this issue 1 year ago • 4 comments

  Uncaught TypeError: globalThis.XMLHttpRequest is not a constructor
    at null.<anonymous>
  (file:///home/someone/foobar/node_modules/rollup-plugin-node-polyfills/polyfills/http-lib/capability.js:20:11)
  in checkTypeSupport
    at null.<anonymous>
  (file:///home/someone/foobar/node_modules/rollup-plugin-node-polyfills/polyfills/http-lib/capability.js:39:45)
  in node_modules/rollup-plugin-node-polyfills/polyfills/http-lib/capability.js
    at null.<anonymous> (worker.js:9:58) in __init
    at null.<anonymous>
  (file:///home/someone/foobar/node_modules/rollup-plugin-node-polyfills/polyfills/http-lib/request.js:1:1)
  in node_modules/rollup-plugin-node-polyfills/po

even upgrading node modules did not help and https://github.com/apacheli/web-workers-polyfill also refused to work ( or my skills are not on that level to implement it )

ty

the-hidden-eye avatar Feb 27 '24 01:02 the-hidden-eye

Hello, can you provide a few more details, so I can try to reproduce the problem?

Things that would be useful:

  • Node.js version you are using
  • Which version of worker-planet are you using? The current master branch?
  • At which stage did this error happen? (did you run npm install and npm run build successfully)?

dethos avatar Feb 27 '24 16:02 dethos

node v18.17 current master from git during wrangler deploy ( obviously one of the libs tries to use XMLHttpRequest whereas CF workerrs only support fetch() )

the-hidden-eye avatar Feb 28 '24 13:02 the-hidden-eye

Got it to work. For those interested.

  1. My RSS feed didn't had a pubDate field but a a10:updated field. This required 2 changes
  • In the parser let parser = new Parser({customFields:{item: ['a10:updated']}})

  • Setting the custom date field:

for (let item of contentFeed.items) {
    item.source_title = contentFeed.title
    item.source_link = contentFeed.link
   
   
    if ('content:encoded' in item) {
      item.content = item['content:encoded']
    }
    // This was the added part
    if(item['a10:updated'] && !item.pubDate){
      item.pubDate = item['a10:updated'];
    }
  }
  1. Saving to RSS and Atom failed in the cronjob ( something with time). Since i'm only interested in HTML, i disabled 3 lines because of that:
// let feed = createFeed(content)
...
// await WORKER_PLANET_STORE.put('rss', feed.rss2())
// await WORKER_PLANET_STORE.put('atom', feed.atom1())
  1. It took a while to get the cronjob locally. So i executed the cronjob untill that part succeeded ( don't forget to remove it again) In the function handleRequest, execute: await handleScheduled();

Don't forget to remove this part again :)

NicoJuicy avatar May 20 '24 20:05 NicoJuicy

@NicoJuicy thanks for the feedback.

However, I think it is unrelated to the original problem described in this issue.

The “date” stuff is definitely worth an independent issue.

  1. It took a while to get the cronjob locally. So i executed the cronjob untill that part succeeded ( don't forget to remove it again) In the function handleRequest, execute: await handleScheduled();

I want to add a way to more easily fetch and test the content when developing (could also be useful for the first deploy). I'm still figuring out the best way to achieve this.

dethos avatar May 22 '24 08:05 dethos