mandarineorg / mandarinets

Mandarine.TS is a typescript, decorator-driven framework that allows you to create server-side applications. Mandarine.TS provides a range of built-in solutions such as Dependency Injection, Components, ORM and more. Under its umbrella, Mandarine.TS has 4 modules: Core, Data, Security and MVC, these modules will offer you the requirements to build a Mandarine-powered application.

Home Page:https://www.mandarinets.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue: @Session() injection undefined on windows

peanutbother opened this issue · comments

[Details]

On windows hosts the session variable is undefined when using @Session().

[Scenario]

Steps to reproduce the behavior:

  1. clone https://github.com/peanutbother/restrorum
  2. run deno:

deno run -c tsconfig.json --import-map=./lib/resources/import-map.json --allow-all --unstable

[Expected behavior]

https://github.com/peanutbother/restrorum/blob/3effb1810fde7a919da52cd83fb31168be1549aa/lib/controllers/MyController.ts#L21
session should be defined and initialized as empty object {}

[OS]

Microsoft Windows [Version 10.0.19042.804] x64

[Environment]

  • Mandarine version: v2.3.2
  • Deno version: 1.7.2(release, x86_64-pc-windows-msvc)
  • Deno v8 version: 8.9.255.3
  • Deno typescript version: 4.1.3

[Additional]

@andreespirela pointed out, that this could be a cross-platform issue.

Cannot reproduce in Microsoft Windows 10 Enterprise edition 10.0.17134 Build 17134. Will keep investigating

Cannot reproduce anymore either.
Seems like something fluctuated, as I can now run it without issues.
Will close for now, as it is not reproducible.

So I closed this too early since this bug seems to show once I restarted debugging from the same code, which gave me undefined again.

This clearly needs more investigation, reopening.

This bug was reproducible for me again and I think I found the issue why it wasn't reproducible in the first run.

In my repo there is a file called .env.sample which is the sample .env file for my project.
I use the MANDARINE_PROPERTY_FILE environment variable to load my custom properties.json file for mandarine.
This would normally get loaded from a different folde since I have a different folder structure.

Please try to rename said .env file so it gets loaded. After that, you will see my bug occur in code.
I will append this info to my repo.

I think this has to do with the session container configuration and something being ignored from the properties.json. Will investigate into it & try to have a fix for today.

can you try setting enableSessions inside mandarine.server to true.?

{
  "mandarine": {
    "server": {
      "port": 8080,
      "host": "localhost",
      "enableSessions": true
    },
    "resources": {
      "staticFolder": "./lib/resources/assets"
    },
    "templateEngine": {
      "path": "./lib/resources/templates"
    }
  }
}

& let me know what happens @peanutbother

this was indeed the missing piece of information - it all works now, so I'll close this again.
The lack of documentation about this should get tracked, as @andreespirela pointed out, we should track it in #273